I am working on a Spring app that leverages websockets facility. To make it more robust I made it to use STOMP/SimpleBrokerMessageHandler as explained in documentation. All went well, I've been able to connect the javasctipt client really quickly so I switched to work on Android client using "androidasync" library.
What I discovered was the fact that the Android client (I suppose any other clients as well) does not get any feedback after SUBSCRIBE request was processed by the server. Reading the sources of SimpleBrokerMessageHandler confirms that:
if (SimpMessageType.SUBSCRIBE.equals(messageType)) {
this.subscriptionRegistry.registerSubscription(message);
}
else if (SimpMessageType.UNSUBSCRIBE.equals(messageType)) {
this.subscriptionRegistry.unregisterSubscription(message);
}
else if (SimpMessageType.MESSAGE.equals(messageType)) {
sendMessageToSubscribers(headers.getDestination(), message);
}
else if (SimpMessageType.DISCONNECT.equals(messageType)) {
String sessionId = headers.getSessionId();
this.subscriptionRegistry.unregisterAllSubscriptions(sessionId);
}
else if (SimpMessageType.CONNECT.equals(messageType)) {
SimpMessageHeaderAccessor replyHeaders = SimpMessageHeaderAccessor.create(SimpMessageType.CONNECT_ACK);
replyHeaders.setSessionId(headers.getSessionId());
replyHeaders.setHeader(SimpMessageHeaderAccessor.CONNECT_MESSAGE_HEADER, message);
Message<byte[]> connectAck = MessageBuilder.withPayload(EMPTY_PAYLOAD).setHeaders(replyHeaders).build();
this.clientOutboundChannel.send(connectAck);
}
It clearly shows that it does not return anything back expect of CONNECT case...
I seem to absolutely need to have a way to make sure that client's SUBSCRIBE request has been processed well or rejected, or an exception thrown somewhere in the middle or something like that. How can I verify it has been processed? What is a recommended approach in this case?
I can not just post a fake message to the channel and check if it gets routed back to the client via subscription because other clients may be subscribed to it thus would receive this fake message as well. It is not a good option really.