Event handler bus custom implementation

Hello all,

I would like to implement something very specific so I’ll try to be as precise as possible.

I want to have guaranteed delivery when an event is caught by an @EventHandler. Not with an @EventSourcingHandler, I am just targeting an @EventHandler.
Basically using an external bus to publish those events that would be then consumed asynchronously and in a loosely coupled fashion by the @EventHandler(s).

For example if one @CommandHandler is not able to commit its data, I want to make sure the message itself is not consumed and could be replayed later on.

My first idea was to implement my own custom bus extending EmbeddedEventStore because I am also interested in the event sourcing capabilities offered by this implementation.

Is it possible to solely extend the event published to the @EventHandler(s) and not to the @EventSourcingHandler?
Is the publish() method the good way to do it?


Hello Teiva,

I’m not completely sure how to give you a complete answer, but I can give you two pieces of info.

  1. The @EventSourcingHandler annotation also is a @EventHandler annotation. So if you want to have different behavior between both, I think you have to create/insert your own AnnotatedMessageHandlingMemnberDefinition. I’m not completely sure how to achieve this though, I think it’ll be a lot of work.

  2. The EventStore/Bus first action is to append the event in the store, to ensure ‘history is kept’. The guarantee for an event to eventually be handled in regular @EventHandler annotated functions can be achieved (to some extent) by adding that class to a TrackingEventProcessor.
    The TrackingEventProcessor will move through the events in it’s own thread and will memorize in the ‘Tracking Token’ which events have been skipped. Adding a process to ‘re-handle’ failed events based on what the Tracking Token has memorized, sounds somewhat simpler to me than implementing your own EventStore/Bus (not to say you shouldn’t do it though).

Not sure if this actually helps you, but at least my 2 cents.