I am trying to set a durable subscription for my stomp client using activemq. So far I have worked out to add activemq.subscriptionName for sending the SUBSCRIBE frame:

HashMap<String, String> header = new HashMap<String,String>();
header.put("activemq.subscriptionName","unique-string-for-feed");
connection.subscribe("/topic/location", Stomp.Headers.Subscribe.AckModeValues.CLIENT, header);

But I'm not sure how to do it with the CONNECT frame as there is no method that accepts a hashmap. Do I just set the client id using the client parameter from StompConnection.class?

public void connect(java.lang.String username, java.lang.String password, java.lang.String client)
有帮助吗?

解决方案

To create a durable subscription you need to set a client Id on the STOMP frame and use that same Id every time you connect. Then you need to set the durable subscription name on your subscribe as you have already worked out.

See the ActiveMQ Stomp Documentation.

You can find some good Stomp examples in the ActiveMQ Stomp unit tests as well, see testDurableUnsub in the StompTest.java

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top