简体   繁体   中英

STOMP heart beat tracking using java and activemq-all library

I am consuming a message feed using the below code from a third party message broker. We use the STOMP protocol and the code is developed using the activemq-all library. I have noticed that the connection is hanging occasionally (after every 1-2 weeks without any feed). So I wanted to use the heart-beat feature of STOMP protocol so I have added the heart-beat header for the stompConnection as shown below:

StompConnection stompConnection = new StompConnection();
stompConnection.open(new Socket("ABC", 1234));
HashMap<String, String> headers = new HashMap<>();
headers.put("login", "abcd");
headers.put("passcode", "defghij");
headers.put("heart-beat", "0,10000");//heart-beat header newly added
stompConnection.connect(headers);
stompConnection.subscribe("topic1", "auto");
while(true) {
    StompFrame stompMessage = stompConnection.receive(10000);
    String messageBody = stompMessage.getBody();
    //process messageBody here
}

Now my question is that is there any way to find/trace that my application (above java client) is receiving the heart beats from the sender?

That library is a test support only tool with no support for issues other than those affecting ActiveMQ tests. Using it is risky and not recommended for any production level work. You'd be far better off using a full open source Stomp client with actual support. The track heart beats with this client you would need to drop to the socket level and track the incoming bytes directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM