spring-projects / spring-projects/spring-modulith

Adding `spring-boot-starter-data-jpa` dependency stops `@ApplicationModuleListener` receiving events

Open
#477 6 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Jan 29, 2024.

in: event publication registry meta: waiting for feedback
Dominant language
Java
Stars
1.2k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

the following snippet works until I add the spring-boot-starter-data-jpa dependency.

@EnableScheduling
@SpringBootApplication
public class DemoApplication {

  private ApplicationEventPublisher publisher;

    public DemoApplication(ApplicationEventPublisher publisher) {
        this.publisher = publisher;
    }

    public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

	@ApplicationModuleListener
	public void onCustomEvent(CustomEvent event) {
		System.out.println("Event received!");
	}

	@Scheduled(timeUnit = TimeUnit.SECONDS, fixedRate = 5)
	public void fireEvents() {
		System.out.println("firing event");
		publisher.publishEvent(new CustomEvent());
	}

	record CustomEvent() {}
}

Is there something that I am missing ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.