@EventHandler how it works?

Hi,

If we want to use more than one instance of a “Projector” that handle same events (using “Tracking Event Processor”),

  • Can we be sure that a event only is processed one time (No more than one projector get the event)? How is this implemented?

  • Is the order of the event stream ensured? i mean, the event number 5 never be processed before the event 4?

  • How the “Tracking Event Processor” work for mongo EventStore? is a pulling mechanism? i mean, is a process that is asking to the data base in intervals or how it works?

Thanks!!
Best Regards.

Hi again!

Can we be sure that a event only is processed one time (No more than one projector get the event)? How is this implemented?

Depends on how you set up the TokenStore. If multiple event processor instances share a TokenStore (Jpa, Jdbc or Mongo tokenstore), they will use this to coordinate with one another by claiming events, so then yes you would have that guarantee. If you use separate TokenStores for the processors (like an InMemoryTokenStore, which is the default), all processors would get all events (which is sometimes useful as well).

Is the order of the event stream ensured? i mean, the event number 5 never be processed before the event 4?

If you have a single instance running a single thread, yes. As soon as you run across multiple instances or multiple threads in the same instance, it’s impossible to guarantee full ordering of events. Therefore, Axon allows you to specify a SequencingPolicy to determine which events have to be processed in a guaranteed order, which means they have to be processed in the same thread. Default is to process events relating to the same aggregate on the same thread.

How the “Tracking Event Processor” work for mongo EventStore? is a pulling mechanism? i mean, is a process that is asking to the data base in intervals or how it works?

It’s implemented in EmbeddedEventStore, in exactly the same way for Mongo or RDBMS storage engines. Yes, essentially it’s doing polling, which works but has some obvious downsides. This is one of the things that are solved much more elegantly in AxonDB. AxonDB can actively push events to tracking event processors after the event has been committed, so no polling is required, and events are delivered faster.

Kind regards,

Hi Frans,

Thanks again for your help :-), just a little clarification about question two:

  • So changing the SequencingPolicy can i ensure, even if we are using more than one instance of a “Projector” to process same events, that the events are processed in order? or this is just in case that we are using a single instance (one JVM)?

Best Regards.

Hi,

with the sequencing policy, you indicate which events need to be processed sequentially. It doesn’t matter whether the threads are in the same JVM, or in different ones. If the sequencing policy returns the same value for 2 messages, they will be guaranteed to be processed sequentially, even if you have tracking processor threads across multiple JVMs.

Cheers,

Allard