activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject activemq-artemis git commit: ARTEMIS-989 JMS2 context support custom session modes
Date Thu, 23 Feb 2017 16:42:27 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/1.x a79cf3b2d -> 4ddd969ff


ARTEMIS-989 JMS2 context support custom session modes

(cherry picked from commit 0b829558b32ac1fe34fab3f18cf2730a7a919e7c)


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/4ddd969f
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/4ddd969f
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/4ddd969f

Branch: refs/heads/1.x
Commit: 4ddd969ffcf78d0c26da31a367ba9b6966bcff49
Parents: a79cf3b
Author: Justin Bertram <jbertram@apache.org>
Authored: Thu Feb 23 09:46:59 2017 -0600
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu Feb 23 11:42:21 2017 -0500

----------------------------------------------------------------------
 .../jms/client/ActiveMQConnectionFactory.java   |  5 ++-
 .../integration/jms/consumer/ConsumerTest.java  | 46 ++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ddd969f/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java
index 4d314ce..dee8157 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java
@@ -48,6 +48,7 @@ import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
 import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants;
 import org.apache.activemq.artemis.api.jms.JMSFactoryType;
 import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
 import org.apache.activemq.artemis.jms.referenceable.ConnectionFactoryObjectFactory;
@@ -297,7 +298,9 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions,
Exte
          case JMSContext.AUTO_ACKNOWLEDGE:
          case JMSContext.CLIENT_ACKNOWLEDGE:
          case JMSContext.DUPS_OK_ACKNOWLEDGE:
-         case JMSContext.SESSION_TRANSACTED: {
+         case JMSContext.SESSION_TRANSACTED:
+         case ActiveMQJMSConstants.PRE_ACKNOWLEDGE:
+         case ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE: {
             return;
          }
          default:

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4ddd969f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/ConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/ConsumerTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/ConsumerTest.java
index 7c5cde6..078be00 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/ConsumerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/ConsumerTest.java
@@ -185,6 +185,52 @@ public class ConsumerTest extends JMSTestBase {
    }
 
    @Test
+   public void testIndividualACKJms2() throws Exception {
+      JMSContext context = cf.createContext(ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE);
+      jBossQueue = ActiveMQJMSClient.createQueue(JmsConsumerTest.Q_NAME);
+      JMSProducer producer = context.createProducer();
+      JMSConsumer consumer = context.createConsumer(jBossQueue);
+      int noOfMessages = 100;
+      for (int i = 0; i < noOfMessages; i++) {
+         producer.send(jBossQueue, context.createTextMessage("m" + i));
+      }
+
+      context.start();
+
+      // Consume even numbers first
+      for (int i = 0; i < noOfMessages; i++) {
+         Message m = consumer.receive(500);
+         Assert.assertNotNull(m);
+         if (i % 2 == 0) {
+            m.acknowledge();
+         }
+      }
+
+      context.close();
+
+      context = cf.createContext(ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE);
+
+      consumer = context.createConsumer(jBossQueue);
+
+      // Consume odd numbers first
+      for (int i = 0; i < noOfMessages; i++) {
+         if (i % 2 == 0) {
+            continue;
+         }
+
+         TextMessage m = (TextMessage) consumer.receive(1000);
+         Assert.assertNotNull(m);
+         m.acknowledge();
+         Assert.assertEquals("m" + i, m.getText());
+      }
+
+      SimpleString queueName = new SimpleString(JmsConsumerTest.Q_NAME);
+      Assert.assertEquals(0, ((Queue) server.getPostOffice().getBinding(queueName).getBindable()).getDeliveringCount());
+      Assert.assertEquals(0, getMessageCount((Queue) server.getPostOffice().getBinding(queueName).getBindable()));
+      context.close();
+   }
+
+   @Test
    public void testIndividualACKMessageConsumer() throws Exception {
       Connection conn = cf.createConnection();
       Session session = conn.createSession(false, ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE);


Mime
View raw message