activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-447: add name and version to properties in amqp open frame
Date Wed, 10 Aug 2016 12:57:02 GMT
ARTEMIS-447: add name and version to properties in amqp open frame


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

Branch: refs/heads/master
Commit: 7a012008b7fff5de1a7f0d9bf96fc0c0b16a572d
Parents: ff18527
Author: Gordon Sim <gsim@redhat.com>
Authored: Tue Aug 9 21:41:48 2016 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Wed Aug 10 08:56:44 2016 -0400

----------------------------------------------------------------------
 .../plug/context/AbstractConnectionContext.java |  6 ++++++
 .../tests/integration/proton/ProtonTest.java    | 21 ++++++++++++++++++++
 2 files changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7a012008/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
index 5b5bd00..b1c8bc7 100644
--- a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
+++ b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
@@ -16,6 +16,7 @@
  */
 package org.proton.plug.context;
 
+import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
@@ -24,6 +25,7 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
 import io.netty.buffer.ByteBuf;
+import org.apache.activemq.artemis.utils.VersionLoader;
 import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.engine.Connection;
 import org.apache.qpid.proton.engine.Delivery;
@@ -54,6 +56,7 @@ public abstract class AbstractConnectionContext extends ProtonInitializable
impl
 
    protected AMQPConnectionCallback connectionCallback;
    private final String containerId;
+   private final Map<Symbol, Object> connectionProperties = new HashMap<>();
    private final ScheduledExecutorService scheduledPool;
 
    private final Map<Session, AbstractProtonSessionContext> sessions = new ConcurrentHashMap<>();
@@ -73,6 +76,8 @@ public abstract class AbstractConnectionContext extends ProtonInitializable
impl
                                     ScheduledExecutorService scheduledPool) {
       this.connectionCallback = connectionCallback;
       this.containerId = (containerId != null) ? containerId : UUID.randomUUID().toString();
+      connectionProperties.put(Symbol.valueOf("product"), "apache-activemq-artemis");
+      connectionProperties.put(Symbol.valueOf("version"), VersionLoader.getVersion().getFullVersion());
       this.scheduledPool = scheduledPool;
       connectionCallback.setConnection(this);
       this.handler =   ProtonHandler.Factory.create(dispatchExecutor);
@@ -196,6 +201,7 @@ public abstract class AbstractConnectionContext extends ProtonInitializable
impl
          synchronized (getLock()) {
             connection.setContext(AbstractConnectionContext.this);
             connection.setContainer(containerId);
+            connection.setProperties(connectionProperties);
             connection.open();
          }
          initialise();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7a012008/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java
index cd37bda..aac1599 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java
@@ -59,6 +59,7 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.apache.activemq.artemis.utils.ByteUtil;
+import org.apache.activemq.artemis.utils.VersionLoader;
 import org.apache.activemq.transport.amqp.client.AmqpClient;
 import org.apache.activemq.transport.amqp.client.AmqpConnection;
 import org.apache.activemq.transport.amqp.client.AmqpMessage;
@@ -66,6 +67,7 @@ import org.apache.activemq.transport.amqp.client.AmqpReceiver;
 import org.apache.activemq.transport.amqp.client.AmqpSender;
 import org.apache.activemq.transport.amqp.client.AmqpSession;
 import org.apache.qpid.jms.JmsConnectionFactory;
+import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.messaging.AmqpValue;
 import org.apache.qpid.proton.amqp.messaging.Properties;
 import org.apache.qpid.proton.message.ProtonJMessage;
@@ -211,6 +213,25 @@ public class ProtonTest extends ActiveMQTestBase {
    }
 
    @Test
+   public void testBrokerConnectionProperties() throws Exception {
+      if (protocol != 0 && protocol != 3) return; // Only run this test for AMQP
protocol
+
+      AmqpClient client = new AmqpClient(new URI(tcpAmqpConnectionUri), userName, password);
+      AmqpConnection amqpConnection = client.connect();
+      try {
+         Map<Symbol, Object> properties = amqpConnection.getEndpoint().getRemoteProperties();
+         assertTrue(properties != null);
+         if (properties != null) {
+            assertTrue("apache-activemq-artemis".equals(properties.get(Symbol.valueOf("product"))));
+            assertTrue(VersionLoader.getVersion().getFullVersion().equals(properties.get(Symbol.valueOf("version"))));
+         }
+      }
+      finally {
+         amqpConnection.close();
+      }
+   }
+
+   @Test
    public void testCreditsAreAllocatedOnlyOnceOnLinkCreate() throws Exception {
       if (protocol != 0 && protocol != 3) return; // Only run this test for AMQP
protocol
 


Mime
View raw message