1

I'm working with websocket to push notification using rabbitmq like a message broker. In controller i using SimpMessageTemplate to convertAndSendToUser a message via the nick name of user

@PostMapping("/{nickName}/notification")
public void send(@PathVariable String nickName,
                 @RequestBody NotificationRes notificationRes) {
        messagingTemplate.convertAndSendToUser(nickName, "/exchange/amq.direct/notification", notificationRes);
    }

I make some configuration by using JWT to authorize user and set user to StompHeaderAccessor when user start connecting.

Spring security messaging currently convert send to user. With that endpoint spring will convert it to /exchange/amq.direct/notification-user{session_id}. And rabbitmq will create an auto deleted queue. So, if I have 100 connect in the same time. It will create 100 queue. I want to custom this flow to create one queue and spring will using message header for spring can know the user to send message to.

I did some research about UserDestinationResolver but I still don't know how to make spring can handle with header instead of url like ...-user{session_id}. @.@. What should i do for this situatioin?

NTNT
  • 36
  • 4

0 Answers0