Subscription Queries Example

I was on the webinar this morning where Frans showed how to convert a standard axon application to use subscription queries. I wonder if there are any plans to provide a more relevant example with respect the the front end technology. Specifically, I don’t think too many new projects are going to be using vaadin. More likely they will be using Angular or React or Vue. It would be very interesting to see the strategy employed here. Probably each would be based on the STOMP protocol…

Anyway, are there any plans for building such an example?

Thanks for your great work!

Hi Troy,

Thanks for joining the webinar! I’ll respond to your question below. Since this message may also be read by people who haven’t seen the webinar, I’ll include some context here which might be redundant for you - please bear with me.

First of all, I’d like to clarify that Axon’s subscription queries have absolutely nothing to do with Vaadin. The key reason for using Vaadin in demos is that it allows me to create and adapt front-ends extremely quickly, fully in Java. (I’m not a skilled front-end dev at all.) Most real-life Axon projects use different front-end technology of course.

Axon’s subscription queries are based on Reactor. The result of a subscription query consists of two things: a Mono with the initial result and a Flux with the updates. From that point on, it’s up to you as a developer what to do with this.

If you want to get your updates to an Angular/React/Vue based front-end, Spring 5 will make your life pretty easy. A RestController can simply return the Flux. I’ve added some code to the repository to include a restcontroller like this. For an example on how to combine that with Angular, you might have a look here. If you want to work this out to a complete example, I’ll happily accept a pull request on the repo :slight_smile:

Kind regards,

Thank you Frans!

Wow, spring 5 does make life easy, that was the bit I was missing. I was looking for it to be way harder. You guys also did a brilliant job designing the query handling API, it is very nice to work with. I implemented and tested the server side changes in my project today and it works so well! It’s very cool. I will handle the client side tomorrow. It should be very straight forward with RxJS Observable.

Thank you!