replay, concurrency and distributed commandbus


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


// ids is a List containing the AR ids to replay -> transactionTemplate.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
JdbcCriteriaBuilder jdbcCriteriaBuilder = new JdbcCriteriaBuilder();
Criteria type =“TYPE”).is(“MyAR”)
MyAR instance = inMemoryModelHandler.getProjectedInstance();
// write to db
// remove the snapshot so it gets reconstructed next time the AR is loaded


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?


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…



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 ?



… 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.