Skip to content

Commit cceb341

Browse files
committed
Ensure that basic.cancel doesn't requeue delivered messages
1 parent 88b8da3 commit cceb341

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

test/src/com/rabbitmq/client/test/functional/FunctionalTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static TestSuite suite() {
3737
suite.addTestSuite(RequeueOnConnectionClose.class);
3838
suite.addTestSuite(RequeueOnChannelClose.class);
3939
suite.addTestSuite(DurableOnTransient.class);
40+
suite.addTestSuite(NoRequeueOnCancel.class);
4041
return suite;
4142
}
4243
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// The contents of this file are subject to the Mozilla Public License
2+
// Version 1.1 (the "License"); you may not use this file except in
3+
// compliance with the License. You may obtain a copy of the License at
4+
// http://www.mozilla.org/MPL/
5+
//
6+
// Software distributed under the License is distributed on an "AS IS"
7+
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
8+
// License for the specific language governing rights and limitations
9+
// under the License.
10+
//
11+
// The Original Code is RabbitMQ.
12+
//
13+
// The Initial Developers of the Original Code are LShift Ltd.,
14+
// Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd.
15+
//
16+
// Portions created by LShift Ltd., Cohesive Financial Technologies
17+
// LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008
18+
// LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit
19+
// Technologies Ltd.;
20+
//
21+
// All Rights Reserved.
22+
//
23+
// Contributor(s): ______________________________________.
24+
//
25+
26+
package com.rabbitmq.client.test.functional;
27+
28+
import java.io.IOException;
29+
30+
import com.rabbitmq.client.QueueingConsumer;
31+
32+
public class NoRequeueOnCancel extends BrokerTestCase
33+
{
34+
protected final String Q = "NoRequeueOnCancel";
35+
36+
protected void setUp()
37+
throws IOException
38+
{
39+
openConnection();
40+
openChannel();
41+
channel.queueDeclare(ticket, Q);
42+
}
43+
44+
protected void tearDown()
45+
throws IOException
46+
{
47+
channel.queueDelete(ticket, Q);
48+
closeChannel();
49+
closeConnection();
50+
}
51+
52+
public void testNoRequeueOnCancel()
53+
throws IOException, InterruptedException
54+
{
55+
channel.basicPublish(ticket, "", Q, null, "1".getBytes());
56+
57+
QueueingConsumer c;
58+
QueueingConsumer.Delivery d;
59+
60+
c = new QueueingConsumer(channel);
61+
String consumerTag = channel.basicConsume(ticket, Q, false, c);
62+
d = c.nextDelivery();
63+
channel.basicCancel(consumerTag);
64+
65+
assertNull(channel.basicGet(ticket, Q, true));
66+
67+
closeChannel();
68+
openChannel();
69+
70+
assertNotNull(channel.basicGet(ticket, Q, true));
71+
}
72+
}

0 commit comments

Comments
 (0)