Re: [axonframework] Axon3 + Spring boot websockets

216 views
Skip to first unread message

Steven van Beelen

unread,
Apr 10, 2017, 3:55:25 AM4/10/17
to axonfr...@googlegroups.com
Hi Rich,

The example you give doesn't sound unreasonable to me to be fair.

I haven't pushed the actual events over websockets to a web app before though.
What I did do before on a project, was update our views/query side based on the events applied through Axon, and push the updated view using STOMP - WebSockets.
We just pushed delta's by the way.

In short: having a class with `@EventHandler` annotated functions emit the actual events directly over WebSockets as in your example, should be doable.

Hope this helps.

Cheers,

Steven

On Sat, Apr 8, 2017 at 2:55 PM, Rich beer <beijing...@gmail.com> wrote:
Hello all,

Im trying to set up websocket server in spring in conjunction with axon(3), however I am unsure how to implement this and was wondering if anyone has done something similar and could offer any help :)

Unfortunately my only web socket experience is with Primus and socket.io js :/

My current hope is that perhaps in an axon event handler, the handler would listen to an axon event and then publish that over a web socket  connection.

example: 

public class DreamDemo {

  @Autowired
  WebsocketServer ws;

  @EventHandler
  public void on(SurchargeAppliedToOrderEvent event ) {
    ws.emit("surcharge-applied", new Payload<>(...)) //etc
  }
}

Notes:

1. The server only needs to "send" ws messages (to the client), it does not need to receive data over the web socket. So its only one way per se.

2. If it helps the general overview is:

                        server(axon+spring boot)
     (command --> aggregate --> event handler) ------->websocket(Spring STOMP????)
     ^                                                                                        |
     |                                                                                         |
     |                                                                                         |
     ^---(HTTP POST reqs)------Web App----(web-socket feed)-------<


Any help would be greatly appreciated.

--
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 axonframework+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Allard Buijze

unread,
Apr 10, 2017, 5:00:50 AM4/10/17
to axonfr...@googlegroups.com
Hi Rich,

there is great benefit in sending view models (or better, their deltas), as Steven described. The main advantage is that you get coupling on that model, instead of the entire structure of your events. You would probably need to implement some logic in the client that will also reside somewhere on the server.

If the server only needs to send, you can also consider Server-Sent Events. It's slightly simpler, as it doesn't require an HTTP upgrade. 

Spring Messaging with Stomp is definitely a good way to go.

Cheers,

Allard

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.

--
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.
Reply all
Reply to author
Forward
0 new messages