Subscription query - block in Rest Controller on specific projection version

56 views
Skip to first unread message

Robin Custers

unread,
Apr 15, 2019, 9:25:33 AM4/15/19
to Axon Framework Users
All,

As we are switching the event handling in our application more and more towards tracking event processors but still have a UI that expects a synchronous REST api I was looking into the following example: https://github.com/fransvanbuul/axon-sync-rest-frontend
However this example does not take into account concurrent updates on a projection (the first update on the projection could be triggered by an action of another user and as a consequence the call might return too soon). 

One way this could be done is by having the new version number of the aggregate being returned after the command is processed. I could then block until the projection is updated with at least that version number or a higher one.
Is there a "supported" way to get this version number (as a CommandResultMessage)?

Robin


Allard Buijze

unread,
Apr 17, 2019, 8:39:07 AM4/17/19
to Axon Framework Users
Hi Robin,

you can get the current version of an Aggregate by calling the AggregateLifecycle.getVersion(). For an event sourced aggregate, this is basically the sequence number of the event that was last applied to it. You can return this value as part of your Command's result.

We do have plans to implement this as a standard feature, where we always return the version of the aggregate as a Command's response. This feature hasn't been concretely planned, though.

Kind regards,

Allard Buijze
CTO

T: +31 6 34 73 99 89


--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sam Kruglov

unread,
Jun 27, 2019, 4:26:15 PM6/27/19
to Axon Framework Users
I will try to implement this scenario by filtering query updates by request id
Reply all
Reply to author
Forward
0 new messages