#StackBounty: #spring-boot #spring-amqp #spring-websocket #spring-rabbitmq #spring-rabbit How to get initial data using Spring RabbitMQ…

Bounty: 200

we are using in our application websockets with combination RabbitMQ and I need solve following use-case:

User sing in into JS application, and application starts subscribing websocket topic for new messages.

Consider following situation:

User is offline and new messages comming from multiple sources (for instance messages m1, m2, m3). User isn’t subscribing for these messages yet, so messages are only stored into database. In some point (time T) user sing-in into application and start subscribing, and messages m4, m5, m6 are received via websockets. User needs to know since when, or ID of last stored and not received message which is in this case m3. Or just simple send initial batch of messages when start subscribing. Do you have idea what is elegant way to solve this in spring?

This is my rabbitmq listener which handle message created by another microservice, and publish it to websocket channel which is subscribed by specific user.

@RabbitListener(queues = "${event.queue.message-created}")
public void handleMessageCreatedEvent(MessageCreatedEvent event) {
    simpMessagingTemplate.convertAndSend("/user/" + event.getUsername() + "/exchange/amq.direct/chat.message", event);

When new message arrived to websocket user will handle it. So I need know since when user is listening, or what is last message which which came and user didn’t handle it and have to be fetched additionally via REST.

Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.