Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpMessagingTemplate vs MessageSendingOperations

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?

like image 826
Ken de Guzman Avatar asked Oct 18 '25 12:10

Ken de Guzman


1 Answers

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;
}
like image 93
Artem Bilan Avatar answered Oct 21 '25 02:10

Artem Bilan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!