我正在使用来自第三方消息代理的以下代码来使用消息源。我们使用 STOMP协议(protocol)和代码是使用 activemq-all 开发的图书馆。我注意到连接偶尔会挂起(每 1-2 周没有任何 Feed 后)。所以我想使用STOMP协议(protocol)的心跳功能所以我添加了heart-beat stompConnection
的 header 如下所示:
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
}
现在我的问题是有什么方法可以找到/跟踪我的应用程序(在 Java 客户端之上)正在接收来自发送者的心跳?
最佳答案
该库是一个仅支持测试的工具,不支持除影响 ActiveMQ 测试之外的问题。使用它是有风险的,不建议用于任何生产级别的工作。如果使用具有实际支持的完整开源 Stomp 客户端,效果会好得多。使用此客户端跟踪心跳,您需要下降到套接字级别并直接跟踪传入的字节。
关于java - 使用 java 和 activemq-all 库进行 STOMP 心跳跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53432112/