Skip to content

djselzlein/spring-websockets-rabbitmq-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring WebSockets and RabbitMQ Demo   Tweet

Build Status

Configure Spring WebSockets to use RabbitMQ message broker.

What for?

When working on a multi-instance web application, messaging service may be a problem when hosted by application containers, such as: Wildfly or Tomcat. That is because you may want that all connected web sockets are knowledgeable by any application container and not only by the one it was first registered. So when a message needs to be broadcasted it can truly reach all connected web sockets.

One option to solve this situation is to enable a message broker that will host our channels and operate incoming and routing of messages. In here I use RabbitMQ as message broker.

See this blog post for a complete walk-through

Setup

Before running this demo, make sure you have RabbitMQ server running and accessible. You may either install it or run on Docker.

Default connection information, which is used in this demo:

127.0.0.1:61613

Admin interface, if management plugin is enabled:

127.0.0.1:15672

Default user and password are: guest/guest

Run

  • Clone
  • Run SpringWebsocketsRabbitmqDemoApplication.java

Play

  • Go to http://localhost:8080
  • Cick Connect
  • On a new tab go to same address and Connect
  • Fill in a message and click Send
  • Message should be delivered to WebSockets on both tabs

Great! We have Spring WebSockets working with RabbitMQ as a message broker relay :D

About

Demo project on how to integrate Spring Web Sockets and RabbitMQ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published