简体   繁体   English

使用Java和activemq-all库进行STOMP心跳跟踪

[英]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. 我们使用STOMP协议,并且使用activemq-all库开发代码。 I have noticed that the connection is hanging occasionally (after every 1-2 weeks without any feed). 我注意到该连接偶尔会挂起(每1-2周之后没有任何馈送)。 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: 所以我想使用STOMP协议的心跳功能,所以我为stompConnection添加了心跳头,如下所示:

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? 现在我的问题是,有什么方法可以找到/跟踪我的应用程序(高于Java客户端)正在接收来自发送方的心跳吗?

That library is a test support only tool with no support for issues other than those affecting ActiveMQ tests. 该库是仅支持测试的工具,除了影响ActiveMQ测试的问题外,不支持其他问题。 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. 使用具有实际支持的完整开源Stomp客户端会更好。 The track heart beats with this client you would need to drop to the socket level and track the incoming bytes directly. 跟踪此客户端的心跳,您将需要下降到套接字级别并直接跟踪传入的字节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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