I am creating a simple client-server demo using websockets. In this demo client can subscribe to different topics. Whenever server has anything to send, it will just send the message on the appropriate topic and only subscribed clients will get the same message.
My server should get acknowledgment whenever it sends the message to any topic, but I am little bit confused, how should I get this acknowledgment of the sent message as the sending method returns void
below is my WebSocketConfig class,
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/testApp");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/message").withSockJS();
}
}
Below is how topic subscription happens at client side,
var topic = '/testApp/testTopic';
stompClient.subscribe(topic, function(greeting){
});
below is how my server sending message to particular topic,
String message = "test message";
this.template.convertAndSend(topic, new Chat(message));
above method(i.e. this.template.convertAndSend(topic, new Chat(message));
) returns void
at the end I am able to successfully send message to all/particular subscribed client but don't know how to get assure whether the message is successfully delivered at the other end or not?