replacement for EventProcessingMonitor in axon 3

Hi all,

we are migrating our web application from axon2.4 to axon3.

We use WebSocket to send Events from server to the client and in Axon2.4 we used an EventProcessingMonitor subscribed to a cluster because it is notified after the events are processed by handlers.

In Axon3 we need to find a similar solution to implement the same functionality.
We found two possible candidates in MessageMonitor or MessageHandlerInterceptor but we have not been able to understand how to use them.

Thanks to anyone who can give help


In Axon 3 you can do the same by attaching a listener to the Unit of Work in your event handler. Once the Unit of Work goes into the PrepareCommit phase all events in the publication batch have been processed. That’s the case because the events are processed in a BatchingUnitOfWork, i.e. a UnitOfWork that processes a batch of events at once. After all events have been handled by event listeners registered with the event processor it will go into the PrepareCommit phase.


Oh and obviously you could also attach a MessageHandlerInterceptor to the processor to achieve the same thing. Just make sure you only attach the listener to each unit of work once!

Hi René,
can you give me an example of both your solutions?


This is what I was thinking about (warning: pseudo code):

void on(SomeEvent event) {
UnitOfWork<?> uow = CurrentUnitWork.get();
uow.getOrComputeResource(this.toString(), s -> {
uow.afterCommit(u -> updateClient());
return new Object();

Looking at the above code sample there seems to be a lot of room for improvement :). One option that is being considered is to add an event handler parameter that lets you know if an event was at the end of a batch, e.g.:

void on(SomeEvent event, @LastInBatch boolean lastInBatch) {
if (lastInBatch) {

This will probably make it in the Axon 3.0 final release (but no promises :p).