activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Balachandar R.A." <balachandar...@gmail.com>
Subject Consumer not consume message
Date Tue, 23 Apr 2013 05:18:45 GMT
Hello,

I have an issue. I push 100 messages to the queue with one consumer
initially. The consumer takes the message and starts working. After few
seconds, I start another consumer. The second consumer does not take any
messages from the queue eventhough there are messages pending in the queue.
Ideally, I would expect the second consumer takes the message and process
so that all the messages are processed quickly. Any fix to this?

In my producer side, I use

// Create a connection factory
             ConnectionFactory connectionFactory = new
ActiveMQConnectionFactory(server)

            // Create a connection and start
            Connection connection = connectionFactory.createConnection()

            connection.start()

            // Create a Session
            Session session =
connection.createSession(false,Session.AUTO_ACKNOWLEDGE)

            // Create the destination
            // PHOTOGRAMMETRY_MQ is the queue name
            Destination destination =
session.createQueue("PHOTOGRAMMETRY_MQ")

            // Create a MessageProducer from the Session to the Topic or
Queue
            MessageProducer producer = session.createProducer(destination)
            producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT)

            // Send the message
            TextMessage message = session.createTextMessage(args)
            producer.send(message)

In my consumer side, I use the code below

// Creates a connection factory
            connectionFactory = new ActiveMQConnectionFactory(server)
            consumerfactory = new ConsumerFactory()

            // Create and start a Connection
            connection = connectionFactory.createConnection()
            connection.start()

            // Create a Session
            Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE)

            // Create a queue
            Destination destination =
session.createQueue("PHOTOGRAMMETRY_MQ")

            // Create a MessageConsumer
            MessageConsumer m_cons = session.createConsumer(destination)
            boolean flag = true
            while (flag){
                // Receive message
                Message message = m_cons.receiveNoWait()



With thanks and regards
Balachandar

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message