如何从应用程序本身订阅STOMP消息

时间:2018-01-04 17:48:29

标签: spring stomp spring-websocket

有没有办法如何使用Spring从主题订阅并转发消息到应用程序的另一层(具有给定主题的新监听器)?

考虑以下消息处理程序处理程序,它将消息发送到主题topic/chat/{conversationId}

public class ConversationController{

    @MessageMapping("/chat/{conversationId}")
    @SendTo("/topic/chat/{conversationId}")
    public ConversationMessage createMesage(
            @Payload CreateMessage message,
            @DestinationVariable String conversationId) {

        log.info("handleMessage {}", message);

        return conversationService.create( message );
    }

}

我想听听这个话题并对某些消息采取行动。

public class Bot{

    @SubscribeMapping("/topic/chat/{conversationId}")
    public void subscribeUserMessages(
            @Payload ConversationMessage message,
            @DestinationVariable String conversationId){


            // doesn't work 
    }
}

我也尝试过使用SimpMessagingTemplate.convertAndSend(..),但它也不起作用。也许我做错了什么。

我的应用程序不使用标记完整的消息代理,只是内存代理中的默认代理。

0 个答案:

没有答案
相关问题