how to know if SimpMessagingTemplate.convertAndSend fails?

570 views Asked by At

I am using the Spring implementation for websocket+stomp as server, and the SockJS as client. This works perfectly when the connection is fine. But I am trying to keep the messag resending when the connection is broken. Here is my code.

public void reliableSend(String target, Object data){
    try{
        simpMessagingTemplate.convertAndSend(target, data);
    }
    catch (MessagingException e){
        e.printStackTrace();
        timer.purge();
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                reliableSend(target, data);
            }
        };
        timer.schedule(task, 1000);
    }
}

My problem is I just cannot know convertAndSend fails, it won't throw MessagingException even I have disconnected the network and the websocket connection is broken. Is there a way I can know the failure?

0

There are 0 answers