Skip to content

Commit e223152

Browse files
author
Matthew Sackman
committed
Merging bug 23335 to default
2 parents 34a7d9b + f3a128e commit e223152

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
@@ -585,6 +585,17 @@ Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, b
585585
*/
586586
void basicCancel(String consumerTag) throws IOException;
587587

588+
/**
589+
* Ask the broker to resend unacknowledged messages. In 0-8
590+
* basic.recover is asynchronous; in 0-9-1 it is synchronous, and
591+
* the new, deprecated method basic.recover_async is asynchronous.
592+
* <p/>
593+
* Equivalent to calling <code>basicRecover(true)</code>, messages
594+
* will be requeued and possibly delivered to a different consumer.
595+
* @see #basicRecover(boolean)
596+
*/
597+
Basic.RecoverOk basicRecover() throws IOException;
598+
588599
/**
589600
* Ask the broker to resend unacknowledged messages. In 0-8
590601
* 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
@@ -769,6 +769,14 @@ public Consumer transformReply(AMQCommand replyCommand) {
769769
}
770770
}
771771

772+
773+
/** Public API - {@inheritDoc} */
774+
public Basic.RecoverOk basicRecover()
775+
throws IOException
776+
{
777+
return basicRecover(true);
778+
}
779+
772780
/** Public API - {@inheritDoc} */
773781
public Basic.RecoverOk basicRecover(boolean requeue)
774782
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
@@ -67,7 +67,6 @@ public static TestSuite suite() {
6767
suite.addTestSuite(InvalidAcksTx.class);
6868
suite.addTestSuite(DefaultExchange.class);
6969
suite.addTestSuite(UnbindAutoDeleteExchange.class);
70-
suite.addTestSuite(RecoverAfterCancel.class);
7170
suite.addTestSuite(UnexpectedFrames.class);
7271
suite.addTestSuite(PerQueueTTL.class);
7372

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)