Replay events - can I get access to the original EventIdentifier?

Hi all.

We are in a place where we need to “migrate” all our existing events into a new structure, and trigger new Commands based on state in previous events. This will result in new aggregates being created and updated. We are doing this by attaching a MigratingEventListener (fancy name…) to event playback and running this over all events.
We were thinking to add the original event identifier as metadata to the new events as a source for provenance-information, but I cannot find a way to get hold of the original identifier, using:

public void on(final ArchivalRecordLocallyDescribedEvent event, EventMessage msg, MetaData m) {
  String id = msg.getIdentifier();

However, the ID i get from this function is a new identifier, not the original. MetaData only contains the metadata (from the metadata column) of the original event, and in most cases is empty (as we have no metadata for most of our events).

Is there some way I can get hold of the original event identifier that I haven't seen yet?

Any help would be much appreciated :)

Trond Marius

Hi, the id is stored in your event -> EventMessage.getPayload();
If you have some interfaces for your identifier (e.g DomainIdentifier) you can easily pick it. Or if identifier is each time the same type with same name you can get it with reflection.

Hi Trond,

which Axon version do you use? Specific older versions of Axon had an issue where the aggregateIdentifier was returned instead of the eventId. This should be fixed in 2.4.
Something that could also change the identifier of the Message is interceptors. When they change the message, for example by adding meta data.