Skip to content

DomainEvent emitted again in EventListener #2575

Open
@shardt68

Description

@shardt68

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions