activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kalpana Jalawadi <kalpana.jalaw...@gmail.com>
Subject Re: Using FailoverTransport
Date Sat, 24 Apr 2010 08:43:55 GMT

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.jalawadi@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.


Mime
View raw message