spring-projects / spring-projects/spring-data-commons
DomainEvent emitted again in EventListener
Open
@odrotbohm is already working on this.
Since Mar 28, 2022.
status: feedback-provided
- Dominant language
- Java
- Stars
- 838
- Forks
- 730
- PR merge metrics
- No merged PRs in 30d
Description
A DomainEvent is emitted again when calling save or delete on the emitting Entity in the EventListener.
there is an Entity
- implementing AbstractAggregateRoot
- with a method registering a DomainEvent
a Service
- is calling the method registering a DomainEvent
- saving the Entity with the repository
in a @EventListener method - the entity is taken from the event or looked up via repository
- the entity is saved or deleted via the repository
- the DomainEvent is emitted again
an infinite loop is starting
If save or delete is called more then one time the event is emitted only once.
There is a demo attached showing the behavior.
demo-reemit-event-in-listener.zip
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.