SimpMessagingTemplate vs MessageSendingOperations

走远了吗. 提交于 2019-12-11 02:18:50

问题


I've just started to study Spring 4 stomp over websocket. What are the differences between these two? What cases should I use one over the another?


回答1:


There is no difference: MessageSendingOperations is an interface - contract. SimpMessagingTemplate is a concrete implementation of the first one.

Typically it's enough to configure bean for concrete implementation, but inject it by type of its conctract:

@Bean
public MessageSendingOperations messagingTemplate() {
    return new SimpMessagingTemplate(this.inputChannel);
}

...

@Component
public class MyService {

   @Autowired
   private MessageSendingOperations  messagingTemplate;
}


来源:https://stackoverflow.com/questions/22856400/simpmessagingtemplate-vs-messagesendingoperations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!