Hi Marco (Connection#stop() won't help - it's semantics are defined by JMS and merely stops the incoming flow of messages).
I think you will be able to achieve your requirements with a custom implementation of FailoverMethod. The FailoverMethod interface is designed as an extension point to the client and gives you the ability to control exactly how failover behaves and the conditions under which failover attempts should continue. Take a look at the existing implementations of FailoverMethod and particularly the failoverAllowed() method. It is the failoverAllowed() method that the client uses to determine if it should continue the failover over attempts. See [1] for details of how you pass your custom implementaion to the client (see the class option to the failover connection url argument. See also FailoverPolicyTest#test..DynamicallyLoaded..). You could implement your own FailoverMethod from scratch, or possibly wrap an instance of FailoverRoundRobinServers, delegating to its methods, whilst controlling the failoverAllowed method to suit your own requirements. I haven't tried this myself, but see no reason why it won't work. [1] http://qpid.apache.org/releases/qpid-0.22/programming/book/QpidJNDI.html#section-jms-connection-url Hope this helps. Keith. On 26 July 2013 14:39, pela <mpela.ga...@gmail.com> wrote: > Connection.stop() and close() don't seem to help. > > Returning false from preFailover() is not a solution because that is > invoked > once before the start of a failover, but my problem is when the failover is > already started when you try to shut down. > > I'm starting to think I'll have to give up with the automatic failover, and > implement a reconnection logic myself... > > Thanks > Marco > > > Phil Harvey-2 wrote > > I'm surprised that calling Connection.stop() doesn't abort failover. > > > > Nevertheless, to abort failover I believe you can just return false from > > org.apache.qpid.jms.ConnectionListener.preFailover(). I guess your > > implementation would return false if the application was trying to shut > > down. > > > > I don't think the behaviour of ConnectionListener is very well documented > > so the best reference I can find is the source code itself: > > > > > http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionListener.java?revision=1460483&view=markup > > > > Phil > > > > On 26 July 2013 09:59, pela < > > > mpela.gatti@ > > > > wrote: > > > >> Hi, > >> > >> The number of retries has been configured to an arbitrary high number, > my > >> application should not give up but just retry forever until stopped by > >> the > >> user. > >> > >> Let me explain futher, the problem can come in two flavors: > >> > >> 1) I call the createConnection() on the factory, but the connection > >> cannot > >> be established. QPID starts its retry loop. The user tries to stop the > >> application, but I don't know how to stop QPID from looping (the > >> createConnection() hasn't yet returned so I can't even call close() ). > >> > >> 2) The connection can be established successfully, but it gets lost at > >> some > >> point. QPID starts its retry loop in its own thread. When the user tries > >> to > >> stop the application, I call stop() on the connection, but QPID doesn't > >> exit. > >> > >> Do you have any idea? > >> > >> Thanks > >> Marco > >> > >> > >> > >> > > > > > > -- > View this message in context: > http://qpid.2158936.n2.nabble.com/Java-client-Cannot-stop-during-failover-tp7595882p7595945.html > Sent from the Apache Qpid users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org > For additional commands, e-mail: users-h...@qpid.apache.org > >