Thank you so much for the test case example!
Gary Tully wrote: > > No need to reference the FailoverTransportFactory, it is easier than you > think, read again Dejan's reply and have a look at one of the tests for > the > failover feature: > http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerTest.java?view=markup > > On 24 April 2010 09:43, Kalpana Jalawadi <kalpana.jalaw...@gmail.com> > wrote: > >> >> Hi, >> Thanks for the reply. >> Below is the code snippet I'm using, kindly check if this is the right >> way. >> >> try { >> failoverTransportFactory = new FailoverTransportFactory(); >> >> Map<String, String> params = new HashMap<String, >> String>(); >> failoverTransport = >> failoverTransportFactory.createTransport(params); >> failoverTransport.add("tcp://localhost:61616"); >> failoverTransport.setTransportListener(new Listener()); >> failoverTransport.setMaxReconnectAttempts(1000); >> failoverTransport.setReconnectDelay(15000); >> failoverTransport.setUseExponentialBackOff(true); >> failoverTransport.setTimeout(3600000); >> failoverTransport.start(); >> >> connectionFactory = new ActiveMQConnectionFactory(null, >> null, "tcp://192.168.150.46:61616"); >> connection = (ActiveMQConnection) >> PubSubClient.connectionFactory.createConnection(); >> connection.setClientID(clientId); >> connection.setExceptionListener(new ExceptionHandler()); >> connection.start(); >> >> session = connection.createSession(false, >> Session.AUTO_ACKNOWLEDGE); >> topic = (ActiveMQTopic) session.createTopic(topicName); >> } catch (InterruptedIOException e) { >> e.printStackTrace(); >> } catch (Exception e) { >> e.printStackTrace(); >> } >> >> According to my understanding, Failovertransport, is basically >> establishing >> a reliable transport connection to the JMS provider. In the event of any >> problem at the provider, the client gets notified. And then, rest of the >> job >> of creating a connection, session remains the same. >> >> Thank you! >> >> >> >> Dejan Bosanac wrote: >> > >> > Hi, >> > >> > you the normal JMS code for that (find any JMS tutorial on the topic). >> The >> > only thing that is different in failover case is broker url you use >> > (e.g >> failover:(tcp://primary:61616,tcp://secondary:61616)?randomize=false) >> > >> > See >> > http://activemq.apache.org/failover-transport-reference.htm< >> http://activemq.apache.org/failover-transport-reference.html>l >> > for more info. >> > >> > Cheers >> > -- >> > Dejan Bosanac - http://twitter.com/dejanb >> > >> > Open Source Integration - http://fusesource.com/ >> > ActiveMQ in Action - http://www.manning.com/snyder/ >> > Blog - http://www.nighttale.net >> > >> > >> > On Fri, Apr 23, 2010 at 11:32 AM, Kalpana Jalawadi < >> > kalpana.jalaw...@gmail.com> wrote: >> > >> >> >> >> Hi, >> >> Could anybody post a code snippet for acquiring a connection & session >> >> over >> >> a FailoverTransport. >> >> >> >> Thanks in advance. >> >> -- >> >> View this message in context: >> >> http://old.nabble.com/Using-FailoverTransport-tp28338986p28338986.html >> >> Sent from the ActiveMQ - User mailing list archive at Nabble.com. >> >> >> >> >> > >> > >> > ----- >> > Dejan Bosanac >> > >> > Open Source Integration - http://fusesource.com/ >> > ActiveMQ in Action - http://www.manning.com/snyder/ >> > Blog - http://www.nighttale.net >> > >> >> -- >> View this message in context: >> http://old.nabble.com/Using-FailoverTransport-tp28338986p28348889.html >> Sent from the ActiveMQ - User mailing list archive at Nabble.com. >> >> > > > -- > http://blog.garytully.com > > Open Source Integration > http://fusesource.com > > -- View this message in context: http://old.nabble.com/Using-FailoverTransport-tp28338986p28366993.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.