I am using spring-websocket to push messages to browser clients.
My setup is almost identical to the one in the portfolio example and I send out messages by using MessageSendingOperations:
MessageSendingOperations<String> messagingTemplate = //...;
this.messagingTemplate.convertAndSend("/topic/data/1", message);
This works perfectly.
But I would also like to be able to subscribe to the same messages internally.
MessageReceivingOperations almost looks like the one to use, but it only seems to support pulling messages. I would much prefer having the messages pushed to my service.
SubscribableChannel.subscribe() also looks promising, but how do I get hold of the correct channel?
I would really like to be able to call something like
messagingTemplate.subscribe("/topic/data/*",
new MessageHandler<String>{
public void handleMessage(String s){
// process message
}
});