With -1 you're basically telling it to keep trying until the connection to your server is back. So, it's doing what it is supposed to do.
Say you temporarily missed the connection to the server. It needs to finish the operation accordingly to what you configured.
In my case, the app is just hanging out listening to a topic. Even if the HornetQ server is down, I need to be able to exit. Any suggestions?
The client doesn't know the server is down. You're telling your client to keep trying the reconnection.
If you need a different behaviour, use a different reconnect attempt value.
Well, I guess I want it both ways - I'm greedy that way :-)
I want the reconnect logic to do its thing during normal opearation of the app. But I also want the close() method to return when the app is trying to exit.
I guess what you are telling me is there is no way to get both of those at the same time.
Is it possible to add an exception listener and have the app reconnect when the server goes down? I pursued this approach, but, based on the exception sent to the app, the app cannot discriminate between:
a. the server (in a non-primary/backup configuration) going down (in which case, it should try to reconnect), and
b the primary server in a primary/backup configuration going down and HornetQ handling the switchover to the backup (in which case, it should NOT try to reconnect)
In each scenario, my apps exception listener receives this exception: javax.jms.JMSException: HornetQException[errorCode=4 message=The connection was disconnected because of server shutdown].
When you do a close, the client will close consumers on the servers, delete temporary queues if used.. and other cleanup that are needed.
You probably need this for a test scenario. If you had it both ways you would eventually break your production use case.
Actually - I'm with Bill on this one.
If a user calls close() on a connection it should terminate it's retry logic and exit.
This wouldn't be hard to do.
Bill, you could add a JIRA feature request for this...