Spring boot Stomp WebSocket multiple session for same user

Viewed 810

I have a spring boot application where I am using Stomp over websockets and using RabbitMQ as external message broker. Our application is using spring security as well. Same authenticated user can get logged inn using different browsers. User can subscribe at some destination to fetch live data feeds using Js client of SockJS. At backend we use simpleMessageTemplate.convertAndSentToUser method to push live feeds to particular authenticated user.

Issue we are facing is that when user login using browser A and subscribe to a destination, A Unique queue like data-feeds-user123 is created at RabbitMq with auto-delete policy, and same user login from different browser B but does not subscribe to destination. Now when backend publishes live data feed using convertAndSendToUser method, A strange behaviour happens A new queue is created data-feeds-321 and messages are published at both queues. Although queue data-feed-321 does not have any consumer and it does not gets deleted when user gets disconnected/close session. Such queues seems useless in such scenario and does not get purged automatically.

Can anyone help me out on this, I don’t want to broadcast the messages unless user subscribed from JS client.

0 Answers
Related