PayloadRevision in TrackingEventProcessor

Hi Axon Team,

Is there a way to obtain the PayloadRevision (from the DomainEventEntry table) in the @EventHandler of a TrackingEventProcessor? I was hoping that I could use an annotation similar to @Timestamp or @Payload, but there doesn’t seem to be a ParameterResolver for PayloadRevision? I would like to use this information when I replay events.

Do you have any suggestions/solutions?

Thank you,
Jose

Hi Jose,

At the moment the payload revision of any event is maintained within the entity and not transitioned over to the EventMessage given to your Event Handling functions.
As such, there is no parameter resolver in place to resolve this parameter from the EventMessage in to your @EventHandler annotated methods.

However, note that from within an Axon application where you have revisions of a given event, you will also have upcasters for said event.
These upcasters will ensure that the event given to your Event Handling function is always the latest.

So, in essence, you can deduce the revision number by checking the annotation on the Event class.

Let me ask you one question in return though.
What is the use case for knowing the revision number of an event during a replay?

Cheers,
Steven

Hi Steven,

Thanks for the quick reply. We use the TEP to send events to a message bus and would like to use the payloadRevision as additional metadata for downstream consumers. Would it be unreasonable to query the domainevententry table for the payloadrevision each time the @EventHandler is called? I was thinking of creating a ParameterResolver that would effectively do that.

Thanks,
Jose

Hi Jose,

You could query the event store directly, true, but that might make your process overly slow I think.
If this is an entirely separate component in your system which whilst performing this operation doesn’t obstruct the rest, I think it should be fine.
If it is however of the utmost importance for performance reasons to send out these events to downstream consumers, it might be worthwhile to consider a different approach.

It’s a little hack-y if you ask me, but you could put the payload revision in your events metadata if you want.
The upcasters in Axon Framework do have access to the entirety of the events info, thus also the revision number.
Added, you can also upcast the MetaData of a given event by adding a field.
Through this approach, you could forcefully introduced the payload revision to all your events their metadata, which you can then use to send over to the downstream consumers.

This could be a little overboard though.
Another option you might consider is to introduce a Query Handler which, based on an event identifier retrieves the payload revision of a given event.
I’d then have the downstream consumer, which apparently requires this information, query the payload revision upon receiving any event.
That way you decouple this requirement from the component which pushes the events to that consumer.

So, just some thought how to tackle this for now.
However, if there’s a way to overcome this requirement your downstream consumer has, I’d likely take that route as both approaches aren’t overly elegant I think.

That’s my two cents to the situation, hope this helps you out.

Cheers,
Steven