activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Balachandar R.A." <balachandar...@gmail.com>
Subject Re: Consumer not consume message
Date Wed, 24 Apr 2013 08:41:40 GMT
Hello,

Thanks for the reply. I could fix with the help of jms.prefetchLimit
parameter. Now, I am more concern about a situation where one of consumer
went down while processing the message. How do I handle this? and what
changes need to be done in the code ? The message is not in the queue and
was with the consumer. Now the message itself is lost and producer has any
way to obtain and resend the lost message?

with  regards
Bala

---------- Forwarded message ----------
From: Balachandar R.A. <balachandar.ra@gmail.com>
Date: 23 April 2013 10:48
Subject: Consumer not consume message
To: users@activemq.apache.org


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