Repository: qpid-jms Updated Branches: refs/heads/master c186b3bb0 -> d7db08f54
Update anonymous relay to use a target with null address in line with Addressing spec direction. Relies on update to broker to enable support. Needs finishing. Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/f5c1fbd4 Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/f5c1fbd4 Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/f5c1fbd4 Branch: refs/heads/master Commit: f5c1fbd42b70eabdd1c2fa80a28ca61a4fe60d71 Parents: c186b3b Author: Robert Gemmell <[email protected]> Authored: Mon Nov 10 15:02:47 2014 +0000 Committer: Robert Gemmell <[email protected]> Committed: Mon Nov 10 17:47:10 2014 +0000 ---------------------------------------------------------------------- .../java/org/apache/qpid/jms/JmsSession.java | 2 +- .../jms/provider/amqp/AmqpFixedProducer.java | 5 +- .../qpid/jms/provider/amqp/AmqpSession.java | 12 ++--- .../jms/integration/SessionIntegrationTest.java | 49 ++++++++++++++++++++ .../qpid/jms/test/testpeer/TestAmqpPeer.java | 7 ++- 5 files changed, 64 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f5c1fbd4/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java index 0c8b812..1ea255a 100644 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java +++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java @@ -648,7 +648,7 @@ public class JmsSession implements Session, QueueSession, TopicSession, JmsMessa original.setJMSExpiration(0); } - String msgId = getNextMessageId(producer);; + String msgId = getNextMessageId(producer); if (!disableMsgId) { original.setJMSMessageID(msgId); } http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f5c1fbd4/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java index 8174817..7eb6683 100644 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java +++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java @@ -38,6 +38,7 @@ import org.apache.qpid.proton.amqp.messaging.Outcome; import org.apache.qpid.proton.amqp.messaging.Rejected; import org.apache.qpid.proton.amqp.messaging.Source; import org.apache.qpid.proton.amqp.messaging.Target; +import org.apache.qpid.proton.amqp.messaging.TerminusDurability; import org.apache.qpid.proton.amqp.transaction.TransactionalState; import org.apache.qpid.proton.amqp.transport.DeliveryState; import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode; @@ -233,13 +234,11 @@ public class AmqpFixedProducer extends AmqpProducer { @Override protected void doOpen() { - String targetAddress; + String targetAddress = null; if (resource.getDestination() != null) { JmsDestination destination = resource.getDestination(); targetAddress = session.getQualifiedName(destination); - } else { - targetAddress = connection.getProperties().getAnonymousRelayName(); } String sourceAddress = getProducerId().toString(); http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f5c1fbd4/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSession.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSession.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSession.java index ca28165..5f7ad07 100644 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSession.java +++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSession.java @@ -103,13 +103,13 @@ public class AmqpSession extends AmqpAbstractResource<JmsSessionInfo, Session> { public AmqpProducer createProducer(JmsProducerInfo producerInfo) { AmqpProducer producer = null; - if (producerInfo.getDestination() != null || connection.getProperties().isAnonymousRelaySupported()) { - LOG.debug("Creating fixed Producer for: {}", producerInfo.getDestination()); + // if (producerInfo.getDestination() != null || connection.getProperties().isAnonymousRelaySupported()) { + LOG.debug("Creating AmqpFixedProducer for: {}", producerInfo.getDestination()); producer = new AmqpFixedProducer(this, producerInfo); - } else { - LOG.debug("Creating an Anonymous Producer: "); - producer = new AmqpAnonymousProducer(this, producerInfo); - } +// } else { +// LOG.debug("Creating an AmqpAnonymousProducer Producer: "); +// producer = new AmqpAnonymousProducer(this, producerInfo); +// } producer.setPresettle(connection.isPresettleProducers()); http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f5c1fbd4/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java index ba97522..4d180c6 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java @@ -18,12 +18,16 @@ */ package org.apache.qpid.jms.integration; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.TemporaryQueue; @@ -32,6 +36,12 @@ import javax.jms.TopicSubscriber; import org.apache.qpid.jms.test.QpidJmsTestCase; import org.apache.qpid.jms.test.testpeer.TestAmqpPeer; +import org.apache.qpid.jms.test.testpeer.basictypes.TerminusDurability; +import org.apache.qpid.jms.test.testpeer.basictypes.TerminusExpiryPolicy; +import org.apache.qpid.jms.test.testpeer.matchers.TargetMatcher; +import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageAnnotationsSectionMatcher; +import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageHeaderSectionMatcher; +import org.apache.qpid.jms.test.testpeer.matchers.sections.TransferPayloadCompositeMatcher; import org.junit.Test; public class SessionIntegrationTest extends QpidJmsTestCase { @@ -128,4 +138,43 @@ public class SessionIntegrationTest extends QpidJmsTestCase { testPeer.waitForAllHandlersToComplete(1000); } } + + @Test(timeout = 5000) + public void testCreateAnonymousProducerWhenAnonymousRelaySupported() throws Exception { + try (TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);) { + Connection connection = testFixture.establishConnecton(testPeer); + connection.start(); + + testPeer.expectBegin(true); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + String topicName = "myTopic"; + Topic dest = session.createTopic(topicName); + + //Expect and accept a link to the anonymous relay node + TargetMatcher targetMatcher = new TargetMatcher(); + targetMatcher.withAddress(nullValue()); + targetMatcher.withDynamic(nullValue());//default = false + targetMatcher.withDurable(nullValue());//default = none/0 + + testPeer.expectSenderAttach(targetMatcher); + + //Create an anonymous producer + MessageProducer producer = session.createProducer(null); + assertNotNull("Producer object was null", producer); + + //Expect a new message sent on the above link to the anonymous relay + MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true); + MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true); + TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher(); + messageMatcher.setHeadersMatcher(headersMatcher); + messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher); + testPeer.expectTransfer(messageMatcher); + + Message message = session.createMessage(); + producer.send(dest, message); + + testPeer.waitForAllHandlersToComplete(1000); + } + } } http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f5c1fbd4/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java index 2d02941..bea5d90 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java @@ -458,6 +458,11 @@ public class TestAmqpPeer implements AutoCloseable public void expectSenderAttach() { + expectSenderAttach(notNullValue()); + } + + public void expectSenderAttach(final Matcher<?> targetMatcher) + { final AttachMatcher attachMatcher = new AttachMatcher() .withName(notNullValue()) .withHandle(notNullValue()) @@ -465,7 +470,7 @@ public class TestAmqpPeer implements AutoCloseable .withSndSettleMode(equalTo(SenderSettleMode.UNSETTLED)) .withRcvSettleMode(equalTo(ReceiverSettleMode.FIRST)) .withSource(notNullValue()) - .withTarget(notNullValue()); + .withTarget(targetMatcher); UnsignedInteger linkHandle = UnsignedInteger.valueOf(_nextLinkHandle++); final AttachFrame attachResponse = new AttachFrame() --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
