create an AR from an event sent by another AR

Hi,

this is probably a FAQ, I just want to check if I am doing this right:

I invoke a method on an AR that sends an event. This event is handled by an even listener (Spring Component outside the AR). The event listener creates a command and dispatches it. The command handler for this command creates a new AR (of another type) which in turn sends an event.

is this a correct way to create an AR in a different domain from a change in a domain?

Thanks,

Chris

my actual question is: shouldn’t the listener be inactive during an event replay? otherwise the command will be created again? Or should I make the event Listener replay-proof? i.e. first check whether the second AR already exists before I dispatch the command.

The approach you mentioned is fine. It’s actually very common.
In fact, the event handler you mention could be considered a singleton Saga. It’s a conponent that reacts on events and sends out command, but doesn’t keep state on a per-transaction basis.
As with Sagas, this component should not be placed in a replayable cluster. Use the cluster selectors to prevent that this listener is assigned to one of these clusters.

Hope this help.
Cheers,

Allard