0
votes

I'd like to create a synchronous saga process from sendAndWait command on REST controller to @Endsaga (including middle steps).

The @Endsaga only would be reached after query-side (separated project) send an event (success or failure from read-store query-side), informing Saga about whats happened.

This is part of a validation process to uniqueness email customer using saga pattern described on link below:

http://foreverframe.net/how-to-guarantee-username-uniqueness-with-cqrses/

I'm not sure how to properly make this configuration in Axon.

Can you help me?

Thanks.

1

1 Answers

2
votes

My personal opinion is that option 2 (from the article you have mentioned) is the most pragmatic. I would not agree with cons mentioned for DB on the Command side.

For checking uniqueness, I would use a small command side projection (within command component/package). In Axon, this would be a regular Event handler that will handle events and populate a small table in a denormalized way so you are able to use it for uniqueness checking in your command handler latter. This event handler/processor should be of type Subscribing (https://docs.axoniq.io/reference-guide/configuring-infrastructure-components/event-processing/event-processors#event-processors)

  1. Subscribing event processors will use the same transaction to store event and projection. That is why it is important to use this particular type of event processor here. It is immediately consistent.

  2. Do not expose Axon queries API on top of this repository (projection), simply inject this repository into your aggregate handlers to chek uniqueness. This way the projection API will be only available to your command component to use it and not exposed to the outside world.