From 9dfc81a98121ac26304790dd474a9bb4e3962496 Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Tue, 20 Jan 2015 16:47:50 +0000 Subject: QPID-6294 : Fix issue whereby AUTO ACK receive consumer would only ever receive one message since _currentPrefetch would never be zeroed git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1653293 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/example/Hello.java | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'qpid/java/client/example/src/main') diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java index 7e956698d1..aab08ebf0f 100644 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java @@ -34,6 +34,9 @@ import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; +import org.apache.qpid.client.AMQConnection; +import org.apache.qpid.configuration.ClientProperties; + public class Hello { @@ -42,10 +45,38 @@ public class Hello { } - public static void main(String[] args) + public static void main(String[] args) throws Exception { - Hello hello = new Hello(); - hello.runTest(); + System.setProperty(ClientProperties.AMQP_VERSION, "0-91"); + System.setProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, "0"); + System.setProperty(ClientProperties.DEST_SYNTAX, "BURL"); + + Connection conn = new AMQConnection("127.0.0.1", 5672, "admin","admin", "client", "/"); + + conn.start(); + + Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); + Destination destination = session.createQueue("queue"); + + MessageConsumer consumer = session.createConsumer(destination); + MessageProducer producer = session.createProducer(destination); + + for(int i = 0 ; i < 2 ; i ++) + { + TextMessage message = (TextMessage) consumer.receive(1000l); + System.out.println(message == null ? "null" : message.getText()); + } + for(int i = 0 ; i < 2 ; i ++) + { + TextMessage message = session.createTextMessage("Hello " + i); + producer.send(message); + } + + for(int i = 0 ; i < 2 ; i ++) + { + TextMessage message = (TextMessage) consumer.receive(1000l); + System.out.println(message == null ? "null" : message.getText()); + } } private void runTest() -- cgit v1.2.1