[axonframework] How to approach integrating events on existing persisted entities

Hi Gideon,

there might be easier and more elegant ways than what I’m about to propose, but I would need much more information about your current application.

Probably the easiest way is to use a singleton to make the Event Gateway accessible to your non-Spring-managed classes.
Alternatively, sometimes you can publish the events from the ‘services’ that typically surround your domain classes. In that case, you might be able to inject the Event Gateway into your classes.

If you want Event publishing to take part in the transaction, you will have to start and commit a unit of work as well.
If you are using an event store with a storage engine that stores in the same datasource as your model classes, that’s generally not necessary.

Hope this helps.