开发者

What is the best way to shutdown a durable consumer using JMS?

I have a durable consumer on a JMS topic. I set the client ID, I 开发者_StackOverflow社区can see that it's listed on the queue as a durable consumer.

When I roll out code the server is restarted but I want to queue up the messages that I'm missing while I restart (hence durable). What is the correct way to cleanly shutdown a message consumer so that you close it but still have the queue know to buffer the messages for you

destination = session.createTopic("beacons");
messageConsumer = session.createDurableSubscriber(destination, clientID);

is this the correct way? or will this tell the queue that you no longer want messages delivered when you re-connect?

messageConsumer.close 

in a nutshell I'm looking to be able to restart my service without losing messages from the topic I'm subscribed to, thanks!


AFAIK, close() will simply shutdown that consumer. In order to delete the subscription you need to unsubscribe() from it (a method on Session). You should test this with your chosen JMS provider however in order to be sure they implemented the JMS spec the way it was intended! :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜