本文介绍了SimpMessagingTemplate 与 MessageSendingOperations的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始研究 Spring 4 stomp over websocket.这两者之间有什么区别?我应该在哪些情况下使用一种?
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?
推荐答案
没有区别:MessageSendingOperations
是一个接口——契约.SimpMessagingTemplate
是第一个的具体实现.
There is no difference: MessageSendingOperations
is an interface - contract.SimpMessagingTemplate
is a concrete implementation of the first one.
通常情况下,为具体实现配置 bean 就足够了,但要根据其合约类型注入它:
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;
}
这篇关于SimpMessagingTemplate 与 MessageSendingOperations的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!