activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joesan <codeintheo...@gmail.com>
Subject Re: ActiveMQ Clustering Issue
Date Thu, 23 Aug 2012 06:45:18 GMT
Below is how my Consumer looks like:

*public class Consumer {

    private static String brokerURL =
"failover:(tcp://localhost:61616,tcp://localhost:61617)?maxReconnectAttempts=-1";
    private static transient ConnectionFactory factory;
    private transient Connection connection;
    private transient Session session;
    //private String clientId = "Client1";
    //private static String consumerName = "Consumer1";
    protected static Destination destination;
    
    public Consumer() throws JMSException {
    	factory = new ActiveMQConnectionFactory(brokerURL);
    	connection = factory.createConnection();
    	//connection.setClientID(clientId); 
        connection.start();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        destination = session.createTopic("MYTOPIC.CLUSTERTOPIC"); 
    }
    
    public void close() throws JMSException {
        if (connection != null) {
            connection.close();
        }
    }    
    
    public static void main(String[] args) throws JMSException {
    	try {
        	Consumer consumer = new Consumer();
        	MessageConsumer messageConsumer =
consumer.getSession().createConsumer(destination);
        	//messageConsumer =
consumer.getSession().createDurableSubscriber((Topic)destination,
consumerName); 
        	messageConsumer.setMessageListener(new Listener());
        	    		
    	} catch (Exception ex) {
    		ex.printStackTrace();
    	}
    }
	
	public Session getSession() {
		return session;
	}
}

*

As soon as I have the Master shutdown, my Consumer dies out. I have a
durable Producer and as per my understanding the messages in the topic
should be preserved untill a Consumer is available. Am I right? But I'm
surprised to see that some of my messages that the Producer had sent to the
Topic got lost during the Consumer down time. Any idea as to what I'm doing
wrong here with my Consumer?



--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-Clustering-Issue-tp4655306p4655467.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message