2

My use case considers three actors:

  • A Message Producer (for instance, a Remote Backend);
  • A Message Broker (for instance, RabbitMQ);
  • A Message Consumer (a Spring-based web application on is own AS).

The communication process is as follows:

  1. The Message Producer creates a message (by specifying a recipient) and then sends it to the Message Broker;
  2. The Message Broker relays the message to the Message Consumer;
  3. The Message Consumer receives the message, then delivers it to a specific user (by mapping recipient and username) by using a WebSocket.

Is it possible to implement this scenario?

vdenotaris
  • 13,297
  • 26
  • 81
  • 132

1 Answers1

2

Yes this scenario is definitely possible to implement. Is there any specific part of it that is troubling you? If you are not using the message consumer in your scenario to do anything else you could actually leave that part out and have the message be consumed directly on the browser-side.

This would involve using the STOMP protocol which most message brokers either support out of the box or can be enabled with a plugin (including RabbitMQ btw). On the browser-side then you can use StompJS. Rossen Stoyanchev gave a great talk on this at SpringOne2GX last year - slides are here...

http://rstoyanchev.github.io/s2gx2013-websocket-browser-apps-with-spring/#1

I hope this is useful for you.

dectarin
  • 986
  • 5
  • 15
  • First of all, thank you for the answer. As newbie about Message Broker and WebSocket, I don't understand how properly setup a recipient during the step 1, then how I could implement an handler in Spring in order to send a message only to a specific user during the step 3. – vdenotaris Sep 02 '14 at 15:02
  • this has been covered in various places but the manual itself should give you a good understanding of where to start.. http://docs.spring.io/spring/docs/4.0.2.RELEASE/spring-framework-reference/htmlsingle/#websocket-stomp-handle-user – dectarin Sep 02 '14 at 15:05
  • You may also want to take a look at https://speakerdeck.com/salmar/deep-dive-into-spring-websockets to understand more about the message flow – Sergi Almar Sep 10 '14 at 16:11