replay, concurrency and distributed commandbus

Hi,

We have put a replay mechanism in place that looks like this:

`

// ids is a List containing the AR ids to replay
ids.stream().forEach(id -> transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
JdbcCriteriaBuilder jdbcCriteriaBuilder = new JdbcCriteriaBuilder();
Criteria type = jdbcCriteriaBuilder.property(“TYPE”).is(“MyAR”)
.and(jdbcCriteriaBuilder.property(“AGGREGATEIDENTIFIER”).is(id));
replayingCluster.startReplay(type);
MyAR instance = inMemoryModelHandler.getProjectedInstance();
// write to db
update(instance);
// remove the snapshot so it gets reconstructed next time the AR is loaded
removeSnapshot(instance.getId());
}
}));

`

Basically a replaycluster replays to an eventhandler that reconstructs an in-memory model. When the replay is finished i persist the projection to the DB and also remove the corresponding AR snapshot. Then the transaction is committed.

What i am trying to figure out is how would this behave in a live instance when there are updates going on to the same AR we are trying to replay. Note that we have a distributed commandbus over jgroups with 2 nodes.

AFAICT the replaycluster is not using the distributed commandbus, it’s replaying locally on the node that processed the replay request. This means that its configured BacklogIncomingMessageHandler will also not receive any messages if they happen to be processed by the other node. Does this mean we would need to temporarily place the system in single-node config while doing the replay?

Thanks,
Jorg

Hi Jorg,

I’m afraid your mixing things up. A replay cluster has nothing to do with the Command Bus. It just replays Events from the Event Store and handles them. When Events are published while the cluster is replaying, they can be backlogged (using BacklogIncomingMessageHandler). There is no command bus involved…

Cheers,

Allard

Hi Allard,

OK thanks for pointing this out. But still there is something missing in my understanding. Imagine that while replaying events for AR123 on node1, a new command arrives on node2 for that same AR123. Node2 handles the command and publishes a couple of events. Are these new events going to be backlogged on node2 ?

Jorg

CORRECTION:

… Are these new events going to be backlogged on node1 ?

Hi Jorg,

no, the Cluster instance isn’t aware of any instances running on other machines. So in your case, that event would get handled right away.

That’s also why replays are fundamentally different in Axon 3.

Allard