Reputation: 15475
I have a durable consumer on a JMS topic. I set the client ID, I 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!
Upvotes: 3
Views: 1515
Reputation: 4748
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! :)
Upvotes: 5