I am new to axon framework with spring boot I had query how I can return value of created object from command itself. how to make command to wait for response from query/event handler service that persist in DB Without SAGA. how can I be sure of my data persistence without saga from event handlers.
Hi @Nimakey_Reborned, I see you have a lot of questions there!
So, first of all, welcome to the Eventual Consistent World!
In short, that will answer all of your questions but let me try to break them in small pieces:
how I can return value of created object from command itself
Well, it depends on what you are asking… you can return values from
@CommandHandlers but that’s not a common use case and, IMO, should be avoided as much as possible. In other words, your Command should just do business validation and apply an Event, done.
how to make command to wait for response from query/event handler service that persist in DB Without SAGA
You don’t. Why would you do that? This is the whole point of doing Event Driven Systems. Again, your Command should only* do business validations and apply an Event. This is the responsability of your Command side (a.k.a.
Aggregate). There are patterns you can use to help on that, for example, using a
SubscriptionQuerybefore firing a Command and waiting for updates. You can have a look at how it works here.
how can I be sure of my data persistence without saga from event handlers.
If you Aggregate said that the Command is valid, an Event will be applied and saved on the Event Store. From now you, you are pretty sure the data is persisted, which is always your Event. How your
EventHandlers will react to that is another history and depends on several other pieces of configuration. But the most important to note is that they will always trigger based on Events and since your Event is stored, they will always* trigger.
Hope it helps to clarify a bit. And, if I can recommend you some things to have a look, first of them would be our ref-guide where you can read about general concepts and also our own Academy where you can watch videos about it!