On 9 Sep 2010, at 14:20, [email protected] wrote:
I use Java client and Java-broker. Every time I start a subscriber,
it will
get the messages from the queue. It seems that the messages always
exist in
the queue. How can I make the message removed when it is published
to a
subscriber? I use the default exchange amq.direct and below is the
JNDI
properties:
java.naming.factory.initial =
org.apache.qpid.jndi.PropertiesFileInitialContextFactory
connectionfactory.qpidConnectionfactory = amqp://
guest:gu...@clientid/test?brokerlist='tcp://localhost:5672'
destination.directQueue = direct://amq.direct//message_queue?
routingkey='routing_key'
What does your code look like?
I would expect something like this unit test (note the way the
session is created):
// create (JNDI) and start a connection to your broker
Connection connection = ... ;
connection.start();
// create a non transacted auto-ack session
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
// destination is the queue you are using (JNDI)
Queue destination = ... ;
// number of messages
Integer n = 5;
//send some unique messages to the destination
MessageProducer producer = session.createProducer(destination);
for (int i = 0; i < n; i++)
{
TextMessage text = session.createTextMessage("text");
text.setIntegerProperty("i", i);
producer.send(text);
}
// receive the messages, using a new consumer each time
for (int i = 0; i < n; i++)
{
MessageConsumer consumer = session.createConsumer(destination)
TextMessage text = (TextMessage) consumer.receive();
assertEquals("body incorrect", "text" text.getText());
assertEquals("property incorrect", i, text.getIntegerProperty
("i"));
}
// no more messages on the destination
MessageConsumer consumer = session.createConsumer()
Message empty = consumer.receive(1000);
assertNull("unexpected message", empty);
// finished
connection.close();
Andrew.
--
-- andrew d kennedy ? do not fold, bend, spindle, or mutilate ;
-- http://grkvlt.blogspot.com/ ? edinburgh : +44 7941 197 134 ;
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]