You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Timothy Chen <ti...@evri.com> on 2010/07/10 02:14:03 UTC

Qpid message limit?

Hi all,

I'm very new to qpid, and basically just trying to test publishing 2000
messages and consuming messages in a queue.

Using JMX console, I see that 2000 messages are in the queue, however my
consumer is always just recieving 1000 of them.

My consumer code:

	Connection connection = null;
		MessageConsumer consumer = null;
		try {
			Properties properties = new Properties();
			properties.put(Context.INITIAL_CONTEXT_FACTORY,
					"org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
			properties.put("connectionfactory.local",
					"amqp://guest:guest@clientid/test?brokerlist='localhost'");
			// Create the initial context
			Context _ctx = new InitialContext(properties);

			ConnectionFactory connectionFactory = (ConnectionFactory) _ctx
					.lookup("local");
			connection = connectionFactory.createConnection();

			connection.setExceptionListener(this);
			connection.start();
			Session session = (Session)connection.createSession(false,
					Session.CLIENT_ACKNOWLEDGE);
			
			Destination destination = session.createQueue(_queueName);
			consumer = session.createConsumer(destination);
			Message msg;
			while (running) {
				msg = consumer.receive(2000);
				onMessage(msg);
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			consumer.close();
			connection.stop();
			connection.close();
		}

I wonder what is wrong with the queue setup or my consumer code?

Also I wonder how to delete message in the queue once it's delivered to
the client?

Thanks,

Tim


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


RE: Qpid message limit?

Posted by Robbie Gemmell <ro...@gmail.com>.
Are you acknowledging the messages in the onMessage() method you pass them into? Since you are using CLIENT_ACKNOWLEDGE mode for your session your application code needs to explicitly acknowledge the messages to allow the broker to actually remove them from the queue and ensure more messages are provided to the client.

Robbie

> -----Original Message-----
> From: Timothy Chen [mailto:tim@evri.com]
> Sent: 10 July 2010 01:14
> To: users@qpid.apache.org
> Subject: Qpid message limit?
> 
> Hi all,
> 
> I'm very new to qpid, and basically just trying to test publishing 2000
> messages and consuming messages in a queue.
> 
> Using JMX console, I see that 2000 messages are in the queue, however
> my
> consumer is always just recieving 1000 of them.
> 
> My consumer code:
> 
> 	Connection connection = null;
> 		MessageConsumer consumer = null;
> 		try {
> 			Properties properties = new Properties();
> 			properties.put(Context.INITIAL_CONTEXT_FACTORY,
> 
> 	"org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
> 			properties.put("connectionfactory.local",
> 
> 	"amqp://guest:guest@clientid/test?brokerlist='localhost'");
> 			// Create the initial context
> 			Context _ctx = new InitialContext(properties);
> 
> 			ConnectionFactory connectionFactory =
> (ConnectionFactory) _ctx
> 					.lookup("local");
> 			connection = connectionFactory.createConnection();
> 
> 			connection.setExceptionListener(this);
> 			connection.start();
> 			Session session =
> (Session)connection.createSession(false,
> 					Session.CLIENT_ACKNOWLEDGE);
> 
> 			Destination destination =
> session.createQueue(_queueName);
> 			consumer = session.createConsumer(destination);
> 			Message msg;
> 			while (running) {
> 				msg = consumer.receive(2000);
> 				onMessage(msg);
> 			}
> 		} catch (Exception ex) {
> 			ex.printStackTrace();
> 		} finally {
> 			consumer.close();
> 			connection.stop();
> 			connection.close();
> 		}
> 
> I wonder what is wrong with the queue setup or my consumer code?
> 
> Also I wonder how to delete message in the queue once it's delivered to
> the client?
> 
> Thanks,
> 
> Tim
> 
> 
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org