Add globalindex to AbstractDomainEventEntry

Hi everyone,

I am working with the Axon Framework on my current project. My focus is especially with event processing from an existing event store. One thing that has been noticeably absent in event messages is the globalindex of the domainevententry table. This value is not added to the AbstractDomainEventEntry class and cannot be accessed from a DomainEventMessage. Is there a reason why this value is not added to the event message?

The value is a surrogate key for the aggregateidentifier and sequencenumber. Under normal circumstances, the globalindex is redundant. However, I have a more uncommon use case in that our system has a transaction entity that spans multiple aggregates. Therefore, it would be helpful to read the stream of events using that transaction key and the simplest way to get an ordering of events is the globalindex. This is especially true because tracking tokens use the globalindex to process an event stream. In looking at the Axon Framework source code, I see no particular reason to throw the globalindex away when constructing the domain event entry in the EventStorageEngine. Would it be acceptable to set up a PR that adds the globalindex to the event messages?

Cheers,
Eric

Hi Eric,

As you’ve probably seen yourself if you’ve went through the source code, only on creation of a Domain Event Entry is the global index added, just not when fetching the data.
Why this decision’s been made, is not completely clear to me, I think Rene or Allard might be able to answer that.

However, as I know what project you’re on, I think I can suggest an approach which would give you the global index. That would require introducing your own Domain Event Entry and adjusting the Event Storage Engine (like you’ve already done) so that when it’s fetching events that it also fills in the global index.

Otherwise, you’re obviously always welcome to put in a issue, feature request or PR on the AxonFramework GitHub of course.

Cheers,

Steven

Hi Eric,

from a conceptual standpoint, events don’t really have a global sequence. They will only have one in the context of a stream in an event store (which is not mandatory). As the JPA Event Store persists all events in a single stream, there is a global sequence there. But in an Event Bus, for example, there is no concept of a global sequence at all.

On a technical level, there is also an issue: certain Event Store implementations do not have a global index. The Mongo based Event Storage Engine doesn’t have these, for example. It sorts events based on their timestamp, instead.

Depending on your situation, you could use the TrackingToken to determine the global sequence. Each EventStorageEngine uses a specific implementation that is suitable for its method of storage, which means you will have to cast to that specific implementation, before being able to access the data.

Hope this helps.
Cheers,

Allard