You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2020/04/29 12:45:38 UTC

[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3104: ARTEMIS-2742 Warn complete XA transaction on the wrong session

clebertsuconic commented on a change in pull request #3104:
URL: https://github.com/apache/activemq-artemis/pull/3104#discussion_r417285683



##########
File path: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaTest.java
##########
@@ -472,6 +473,96 @@ public void testRollbackError() throws Exception {
       }
    }
 
+   private void startXATransaction(Xid xid) throws Exception {
+      ClientProducer clientProducer = clientSession.createProducer(atestq);
+      ClientMessage sentMessage = createTextMessage(clientSession, "TEST");
+      clientProducer.send(sentMessage);
+      sentMessage.acknowledge();
+
+      clientSession.start(xid, XAResource.TMNOFLAGS);
+      clientSession.start();
+
+      ClientConsumer clientConsumer = clientSession.createConsumer(atestq);
+      ClientMessage receivedMessage = clientConsumer.receive(1000);
+      Assert.assertNotNull(receivedMessage);
+      receivedMessage.acknowledge();
+      Assert.assertEquals(receivedMessage.getBodyBuffer().readString(), "TEST");
+
+      clientSession.end(xid, XAResource.TMSUCCESS);
+   }
+
+   @Test
+   public void testPrepareOnWrongSession() throws Exception {
+      ClientSession clientSession2 = sessionFactory.createSession(true, false, false);
+
+      Xid xid = newXID();
+      startXATransaction(xid);
+
+      AssertionLoggerHandler.startCapture();
+      try {
+         clientSession2.prepare(xid);
+
+         assertTrue("Expected to find AMQ224105", AssertionLoggerHandler.findText("AMQ224105"));

Review comment:
       You cannot make this as a rule... 
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org