1
votes

We are using CQRS and Event Sourcing using Axon 4.

We have the following scenario.

Domain Book

  1. Action- Create new Book into DB using the Axon CRQS and event sourcing flow (Command - Aggregate - Event)
  2. Action- Update the already created Book into DB using the Axon CRQS and event sourcing flow (Command - Aggregate - Event)
  3. In the Axon event store this two commands explained above (createCommand and updateCommand) have the same "aggregateIdentifier" id, they are in the same Aggregate tree, because we are working on the same Aggregate root.
  4. In the Axon event store this commands have different "aggregateSequenceNumber", also this is normal and expected

At this point we are doing replay events by processingGroup, and this works fine, now we want to do more complex replay of the events

Question

How can we create resetTokens that will replay only the events with some "aggregateIdentifier" id (one Aggregate tree), this means we want to replay only the events related to some book (Aggregate tree) and not all books ?

Is this functionality supported by the Axon 4 ?

1
I do not understand this. Why would you want to replay only events for certain aggregates?tom
Scenario We have Table Book with 10 000 records (this records are created by commands that exist in the event store). We want to replay only events for Book with Title "Java", we want to see how book with Title "Java" was updated and what commands were used, because some user reported issues with this recordMr.Java

1 Answers

1
votes

You could create this feature with Axon if you'd want, but it requires some custom code using Axon Framework specifics.

Firstly though, this is not a replay as replays are described from an Event Processor level. Replaying an Event Processor will start reading the entirety of the Event Stream from a point in time based on the given token.

What you'd want is to replay and filter for a given aggregate identifier.

From the description in your comment, this feels like a sporadic query a user/service does against your application.

Upon handling this query, you will need to open an Event Stream, filter the events and then use the remaining stream to update the required query model.

From an implementation perspective, I would use a AnnotationEventHandlerAdapter. This class should be given an annotated event listener, which should be the Query Model you want to create ad-hoc and return.

Subsequently, the AnnotationEventHandlerAdapter#handle(EventMessage<?>) method should be called with the filtered event stream. Once you've reached the end of the stream, then you're query model is up to date.

So, to circle back to your question:

Is this functionality supported by the Axon 4 ?

The answer to this is yes, but it requires some handy work from your part.