Axon 4.2: Do a redirect after an event has happened

Hi all,
In our application we want to do a redirect to a new page, only when a certain event has happened. We have looked into subscription queries but in this case we are not really interested in the initial result, we basically only want to do a redirect when the event has happened. In the event handler we eventually store some data in our database and we want to wait for that to have happened, because without that data, the redirect does not make sense. Does anybody have experience with this issue? Also: if we were going to use subscription queries to solve this issue, do we need to create separate queries and handlers for every kind of event where this issue might occur?

Kind regards,
Koen

Hi Koen,

Using the subscription query and ignoring the initial result is also an option in this case.
You essentially want to spoof a synchronize operation right now, which indeed means that the initial result will (very likely) not be up to date yet when you are using the query.
The updates from the subscription query would still work though.

You can see a sample of such an approach here and here.

Also: if we were going to use subscription queries to solve this issue, do we need to create separate queries and handlers for every kind of event where this issue might occur?

From the scenario you’ve described I am assuming you are not using the result from the subscription query at all.
Just the fact you have a response is sufficient to react upon.
Having a distinct query plus query handler for this would make sense to me, just not for every occurrence of such a redirect request.
However, I do think that the redirect you are doing will do a query for the model upon redirection, right?

Aren’t you thus duplicating your traffic somewhat?
Firstly to get notified the stuff is there and then to actually grab it.
Wouldn’t subscribing to the view directly (through a subscription query) be more efficient?

Cheers,
Steven