activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bizcenter <bizcenter...@gmail.com>
Subject master/slave, consumer can not failover
Date Thu, 28 Jun 2012 11:59:32 GMT
*Deploy the brokers with master/slave, when master stops, consumer can not
reconnect to slave.*

code example:
/String brokerUrl = "failover:(tcp://hostA, tcp://hostB)";
try {
                connection = factory.createConnection();
            // if a durable topic subscription, and client id must be unique
            if (durable && null != clientId && clientId.length() > 0) {
                connection.setClientID(clientId);
            }
            connection.setExceptionListener(this);
            connection.start();

            session = connection.createSession(transacted, ackMode);
            if (isTopic) {
                destination = session.createTopic(subject);
            } else {
                destination = session.createQueue(subject);
            }

            if (isTopic && durable) {
                if (null != this.filter) {
                    consumer = session.createDurableSubscriber((Topic)
destination, consumerName, this.filter, false);
                } else {
                    consumer = session.createDurableSubscriber((Topic)
destination, consumerName);
                }
            } else {
                if (null != this.filter) {
                    consumer = session.createConsumer(destination,
this.filter);
                } else {
                    consumer = session.createConsumer(destination);
                }
            }

            if (this.receiveTimeout == 0) {
                consumer.setMessageListener(this);
            } else {
                consumeMessagesAndClose(connection, session, consumer,
receiveTimeout);
            }
// no execution about closing connection, session, consumer/
------------------------------------------------------------------------------------------

anyone can give me a favor? thanks. (my english is poor...)



--
View this message in context: http://activemq.2283324.n4.nabble.com/master-slave-consumer-can-not-failover-tp4653639.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message