diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java index 25ca37c2f2..a0927adcb0 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpConnection.java @@ -492,6 +492,7 @@ public class AmqpConnection implements AmqpProtocolConverter { protonConnection.setOfferedCapabilities(getConnectionCapabilitiesOffered()); protonConnection.setProperties(getConnetionProperties()); + protonConnection.setContainer(brokerService.getBrokerName()); protonConnection.open(); configureInactivityMonitor(); diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java index 27d7e2e002..971b1df299 100644 --- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java +++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/interop/AmqpConnectionsTest.java @@ -113,6 +113,35 @@ public class AmqpConnectionsTest extends AmqpClientTestSupport { assertEquals(0, getProxyToBroker().getCurrentConnectionsCount()); } + @Test(timeout = 60000) + public void testConnectionCarriesContainerId() throws Exception { + AmqpClient client = createAmqpClient(); + assertNotNull(client); + + client.setValidator(new AmqpValidator() { + + @Override + public void inspectOpenedResource(Connection connection) { + String remoteContainer = connection.getRemoteContainer(); + if (remoteContainer == null || !remoteContainer.equals(brokerService.getBrokerName())) { + markAsInvalid("Broker did not send a valid container ID"); + } else { + LOG.info("Broker container ID = {}", remoteContainer); + } + } + }); + + AmqpConnection connection = client.connect(); + assertNotNull(connection); + + assertEquals(1, getProxyToBroker().getCurrentConnectionsCount()); + + connection.getStateInspector().assertValid(); + connection.close(); + + assertEquals(0, getProxyToBroker().getCurrentConnectionsCount()); + } + @Test(timeout = 60000) public void testCanConnectWithDifferentContainerIds() throws Exception { AmqpClient client = createAmqpClient();