EventHandler is not triggered for AsynchronousCommandBus + sendAndWait + Cascading Command ?

Hi ,

I have a DeletionCommand that will be handled and send another DeletionCommand and may send more for cascading deletion . All of DeletionCommands have different global unique TargetAggregateIdentifier.

something like :

  1. sendAndWait(DeletionCommand(“1001”)) in RestController

  2. sendAndWait(DeletionCommand(“1002”)) in Aggregate

  3. apply(SomethingDelevedEvent)

  4. sendAndWait(DeletionCommand(“1003”)) in Aggregate

  5. apply(SomethingDelevedEvent)

It works well with SimpleCommandBus, but when switching to AsynchronousCommandBus , the EventHandler of SomethingDelevedEvent is not triggered anymore and there’s no exception in the log . I’m using subscription query + update emitter for sync UI request, so the UI hangs if EventHandler is not trigger.

If I use send instead of sendAndWait for #2 & #4, then SomethingDelevedEvent is triggered. But I do want the cascading DeletionCommands are executed sequentially.

Why does AsynchronousCommandBus behave like this and how can I run the commands one by one ?

Regards,
Sean

=============update=================

The problem seems only occurs for sending the same type of Command, if send different Command class in the command handler then asynchronousCommandBus also works . But it doesn’t solve my problem as I need recursive deletion command.

Just found where my fault is, the consequent DeletionCommands sometimes have same targetAggregrateIdentifer with the previous ones , so the thread become dead lock with the previous command handler.