Skip to content

Commit f3a128e

Browse files
author
Rob Harrop
committed
reworked tests to account for removal of requeue=false. Added Channel.basicRecover() as a convenience
1 parent 69056dd commit f3a128e

File tree

5 files changed

+47
-44
lines changed

5 files changed

+47
-44
lines changed

src/com/rabbitmq/client/Channel.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,17 @@ Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, b
526526
*/
527527
void basicCancel(String consumerTag) throws IOException;
528528

529+
/**
530+
* Ask the broker to resend unacknowledged messages. In 0-8
531+
* basic.recover is asynchronous; in 0-9-1 it is synchronous, and
532+
* the new, deprecated method basic.recover_async is asynchronous.
533+
* <p/>
534+
* Equivalent to calling <code>basicRecover(true)</code>, messages
535+
* will be requeued and possibly delivered to a different consumer.
536+
* @see #basicRecover(boolean)
537+
*/
538+
Basic.RecoverOk basicRecover() throws IOException;
539+
529540
/**
530541
* Ask the broker to resend unacknowledged messages. In 0-8
531542
* basic.recover is asynchronous; in 0-9-1 it is synchronous, and

src/com/rabbitmq/client/impl/ChannelN.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,14 @@ public Consumer transformReply(AMQCommand replyCommand) {
739739
}
740740
}
741741

742+
743+
/** Public API - {@inheritDoc} */
744+
public Basic.RecoverOk basicRecover()
745+
throws IOException
746+
{
747+
return basicRecover(true);
748+
}
749+
742750
/** Public API - {@inheritDoc} */
743751
public Basic.RecoverOk basicRecover(boolean requeue)
744752
throws IOException

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public static TestSuite suite() {
6565
suite.addTestSuite(InvalidAcksTx.class);
6666
suite.addTestSuite(BindToDefaultExchange.class);
6767
suite.addTestSuite(UnbindAutoDeleteExchange.class);
68-
suite.addTestSuite(RecoverAfterCancel.class);
6968
suite.addTestSuite(UnexpectedFrames.class);
7069
return suite;
7170
}

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import com.rabbitmq.client.AMQP;
3838
import com.rabbitmq.client.QueueingConsumer;
3939
import com.rabbitmq.client.Channel;
40+
import com.rabbitmq.client.Command;
41+
import com.rabbitmq.client.ShutdownSignalException;
4042

4143
import com.rabbitmq.client.test.BrokerTestCase;
4244

@@ -100,13 +102,24 @@ public void recover(Channel channel) throws IOException {
100102
}
101103
};
102104

105+
RecoverCallback recoverSyncConvenience = new RecoverCallback() {
106+
public void recover(Channel channel) throws IOException {
107+
channel.basicRecover();
108+
}
109+
};
110+
103111
public void testRedeliverOnRecoverAsync() throws IOException, InterruptedException {
104112
verifyRedeliverOnRecover(recoverAsync);
105113
}
106114

107115
public void testRedeliveryOnRecover() throws IOException, InterruptedException {
108116
verifyRedeliverOnRecover(recoverSync);
109117
}
118+
119+
public void testRedeliverOnRecoverConvenience()
120+
throws IOException, InterruptedException {
121+
verifyRedeliverOnRecover(recoverSyncConvenience);
122+
}
110123

111124
public void testNoRedeliveryWithAutoAckAsync()
112125
throws IOException, InterruptedException {
@@ -117,4 +130,19 @@ public void testNoRedeliveryWithAutoAck()
117130
throws IOException, InterruptedException {
118131
verifyNoRedeliveryWithAutoAck(recoverSync);
119132
}
133+
134+
public void testRequeueFalseNotSupported() throws Exception {
135+
try {
136+
channel.basicRecover(false);
137+
fail("basicRecover(false) should not be supported");
138+
} catch(IOException ioe) {
139+
ShutdownSignalException sse =
140+
(ShutdownSignalException) ioe.getCause();
141+
Command reason = (Command) sse.getReason();
142+
AMQP.Connection.Close close =
143+
(AMQP.Connection.Close) reason.getMethod();
144+
assertEquals("NOT_IMPLEMENTED - requeue=false",
145+
close.getReplyText());
146+
}
147+
}
120148
}

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

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)