Using events from existing entities

Hello,

What is the best way to incorporate events into an existing system?

In my use case I want to create an event in response to something happening in an already existing system/entity that makes use of jpa entities.
Given I have i.e. an Order that has already been created using JPA entities and I am only interested in OrderProcessed events.
What is the best way to create the OrderProcessed event without making Order completely eventsourced and without creating Order Created events for orders that have already been created.

I know an event always has to have an aggregate identifier.
I am using Spring Boot, but I haven’t found a way to use @Autowired to inject the EventGateway and directly publish an event on the eventgateway.
Is this even a good practice to create events into existing code or is there a better way?

Greetz,
Gideon

Hello Gideon,
In short, you inject the EventBus where needed and publish events. You want to do this in a “higher” layer vs, say, the DAO layer because the lower layers lack context.

You might find this video helpful:
https://www.youtube.com/watch?v=6YZZo19xStw

Thanks Brian!

The video also cleared some things up.

Hi Gideon, Brian,

The EventGateway is indeed not auto configured at this point in time.
Meaning, it’s not a part of release 4.1.x.
It however will be introduced in Axon Framework 4.2, as it has been covered in this ticket.

Once that is in, you’ll have a more user friendly API to publish events directly, which I thought might interest you both.

That’s my 2 cents.

Cheers,
Steven

Thanks Steven,

I did manage to autowire the EventGateway now. I didn’t realize it was not auto configured yet.