tags:

views:

15

answers:

0

I have to connect to a HornetQ running on a remote box. I specifically have to subscribe to a durable topic, so I am notified of any missed messages upon reconnection.

The first thing I noticed is when my client tries to reconnect after disconnecting, I cannot do so - instead, I get the following error:

javax.jms.IllegalStateException: Cannot create a subscriber on the durable subscription since it already has subscriber(s)

At this point, I added in code to unsubscribe the topics during client shutdown. In testing, I can see that my code is being called, but when I restart the client, I get the same error as above.

I suppose my question is 2 fold:
1. Is this the best way to approach implementing a client that needs to be able to reconnect (by unsubscribing during cleanup so you can then resubscribe upon reconnect)?
2. If so, is there something else I need to be doing to remove the subscription from HornetQ so I am allowed to initiation that subscription upon reconnect?

Thanks