access global event sequence number from a listener

Hi all,

In Axon is there a way to access the global event sequence number - which is stored in the event store - from a listener?

Best regards,
Robin

Hi Robin,

With ‘from a listener’, I think you mean from an event handling function as an additional parameter, right?

The functionality in Axon to inject parameters into your message (command/event) handling functions, is through ParameterResolvers.
These ParameterResolvers check the message being sent to the message handling function and try to fill in the additional parameters you’ve specified. You can for example add an additional parameter to an event handling function, @SequenceNumber long sequenceNumber, which will be injected by the SequenceNumberParameterResolver based on information in the ‘Message’ class.

For what you’re asking, the globalSequenceNumber would have to be on the DomainEventMessage, which isn’t the case right now.

Did I understand your question correctly?
Hoping this helps!

Cheers,

Steven

Hi Steven,

You understood my question correctly. So I should/can write my own parameter resolver for the globalSequenceNumber then, right?

Regards,
Robin

Hi Robin,

the globalSequenceNumber currently isn’t exposed as a possible parameter on the @EventHandler methods. You could build that functionality by creating your own ParameterResolverFactory.

If you’re using Spring, all you need to do is define a bean of type ParameterResolverFactory, and it will be automatically picked up by Axon to resolve parameters on @EventHandler methods.

Cheers,

Allard