mirror of https://github.com/apache/activemq.git
NO-JIRA: Adding an extra test on AmqpTransactionTest
The test I'm adding was back ported from Artemis. It will validate if the ACKs are nacked in case of a connection.close(); To avoid a situation where the TX would sit on a Transaction Resource Manager somewhere like an XID.
This commit is contained in:
parent
8e6fe414ad
commit
195046c503
|
@ -150,6 +150,51 @@ public class AmqpTransactionTest extends AmqpClientTestSupport {
|
|||
connection.close();
|
||||
}
|
||||
|
||||
@Test(timeout = 60000)
|
||||
public void testReceiveAfterConnectionClose() throws Exception {
|
||||
AmqpClient client = createAmqpClient();
|
||||
AmqpConnection connection = client.connect();
|
||||
AmqpSession session = connection.createSession();
|
||||
|
||||
AmqpSender sender = session.createSender(getTestName());
|
||||
final QueueViewMBean queue = getProxyToQueue(getTestName());
|
||||
|
||||
AmqpMessage message = new AmqpMessage();
|
||||
message.setText("Test-Message");
|
||||
sender.send(message);
|
||||
|
||||
assertEquals(1, queue.getQueueSize());
|
||||
|
||||
AmqpReceiver receiver = session.createReceiver(getTestName());
|
||||
|
||||
session.begin();
|
||||
|
||||
receiver.flow(1);
|
||||
AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
|
||||
assertNotNull(received);
|
||||
received.accept();
|
||||
|
||||
// this will force a rollback on the TX (It should at least)
|
||||
connection.close();
|
||||
|
||||
connection = client.connect();
|
||||
session = connection.createSession();
|
||||
receiver = session.createReceiver(getTestName());
|
||||
session.begin();
|
||||
receiver.flow(1);
|
||||
|
||||
received = receiver.receive(5, TimeUnit.SECONDS);
|
||||
assertNotNull(received);
|
||||
received.accept();
|
||||
|
||||
session.commit();
|
||||
|
||||
assertEquals(0, queue.getQueueSize());
|
||||
|
||||
connection.close();
|
||||
}
|
||||
|
||||
|
||||
@Test(timeout = 60000)
|
||||
public void testReceiveMessageWithRollback() throws Exception {
|
||||
AmqpClient client = createAmqpClient();
|
||||
|
|
Loading…
Reference in New Issue