Subscription Queries with a javascript client

85 views
Skip to first unread message

Troy Hart

unread,
Oct 19, 2018, 2:14:19 PM10/19/18
to Axon Framework Users
I just wanted to share some work I've done to solve what has been a pretty tricky issue: integrating a javascript front end with subscription queries. 

I have prototype available on gitbub that might help you if you need to do the same thing: https://github.com/troyhart/axon-subscription-queries-sse

My solution uses Server Sent Events and requires a polyfill in order to support IE and also to support the passing of my JWT authentication token. 

Let me know what you think.

Troy

Troy Hart

unread,
Oct 22, 2018, 1:30:23 PM10/22/18
to Axon Framework Users
I've made a bunch of modifications. The front end is a little messy because I am trying to keep it simple by just depending jquery rather than angular or react or something. 

The current implementation demonstrates subscribing to a list of (basket) models in addition to subscribing to a given (basket) model.

One of the issues that I'm still wrestling with is the separation of the initial result with the flux of incremental updates. I feel like there should be a way to subscribe and get the both the initial state back plus the incremental updates. As it it now I must subscribe to the updates and then go get the current state an integrate it all on the client. 

Allard Buijze

unread,
Oct 26, 2018, 6:10:46 AM10/26/18
to axonfr...@googlegroups.com
Hi Troy,

you can merge the initial result and the updates into a single Flux quite easily, if their content types are the same:

Flux<MyResultType> results = r.initialResult().concatWith(r.updates())

Also, why does the client need to fetch the initial result in a separate request? You could simply send the initial result as the first SSE, and the updates following that.

Allard

--
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.
--
Allard Buijze
CTO

E: allard...@axoniq.io
T: +31 6 34 73 99 89

milan...@axoniq.io

unread,
Oct 26, 2018, 6:14:47 AM10/26/18
to Axon Framework Users
Hi all,

As an example of how to combine 'initialResult' and 'incrementalUpdates' you can take a look at this small example I built to demonstrate usage of subscription queries.

Cheers,
Milan

Troy Hart

unread,
Oct 26, 2018, 10:28:49 AM10/26/18
to Axon Framework Users
Allard and Milan,

Thanks for the replies! I still have a lot to learn about Reactor!
Reply all
Reply to author
Forward
0 new messages