How can I handle event asynchronously in axon framework v3.1?

“The recommended approach to handle Events asynchronously is by using a Tracking Event Processor. This implementation can guarantee processing of all events, even in case of a system failure (assuming the Events have been persisted).”
I read this on axon framework guide.
I do not quite understand.
Thx.

I mean the same type of event.

Hi Liu(kaijun),

Axon has two technical mechanisms of providing your events to the @EventHandler annotated functions you’d code in your Event Handling Components.
One of those, which is the default in pre Axon 4 release, is the SubscribingEventProcessor.

The SubscribingEventProcessor receives it’s events as they are published on the EventBus by, for example, the AggregateLifecycle.apply() function.
This thus happens in the same thread and as such ins’t asynchronous.

The TrackingEventProcessor on the other head tracks the EventStore in a separate thread, to retrieve events from the store and provide them to your event handlers.

As such, this is an asynchronous approach to what Axon calls ‘Event Processing’.

To configure this in your Axon 3.1 application, you can use the EventHandlingConfiguration class to register your Event Handling Components by means of their processing group to be backed by a Subscribing or Tracking Event Processing solution.
In a Spring environment you could thus for example have an @Autowired function with the EventHandlingConfiguration as the sole parameter.
In this function, you can thus call the registerSubcribingProcessor/registerTrackingProcessor functions.

Aside of this, I would like to note that Axon is on release 4.0.3 currently, where 4.0 has been out since mid October last year.
We would highly recommend to upgrade to the latest version.

Especially event handler configuration has been improved quite a lot since than, something I would like you to benefit from.

I hope this helps!

Cheers,
Steven

Your reply helps me a lot. Thank you so much.

在 2019年1月7日星期一 UTC+8下午6:58:18,Steven van Beelen写道:

Hi Liu,

Happy to hear that!
Feel free to post more questions in the future if something in regards to Axon isn’t clear for you.

Cheers,
Steven