You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2014/09/25 00:07:01 UTC

[1/3] git commit: Initial stab at message copy, still needs work.

Repository: qpid-jms
Updated Branches:
  refs/heads/master bdc47a55c -> 2943002c3


Initial stab at message copy, still needs work.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/372d5b81
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/372d5b81
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/372d5b81

Branch: refs/heads/master
Commit: 372d5b8150761eb54f4358e0cad780dfba996bca
Parents: bdc47a5
Author: Timothy Bish <ta...@gmail.com>
Authored: Wed Sep 24 17:37:11 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Wed Sep 24 17:37:11 2014 -0400

----------------------------------------------------------------------
 .../amqp/message/AmqpJmsMessageFacade.java      | 56 +++++++++++++++++---
 1 file changed, 48 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/372d5b81/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
index acd3012..dff75f6 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
@@ -227,13 +227,7 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
 
     @Override
     public void clearProperties() {
-        //_propJMS_AMQP_TTL = null;
-        message.setReplyToGroupId(null);
-        message.setUserId(null);
-        message.setGroupId(null);
-        setGroupSequence(0);
-
-        // TODO - Clear others as needed.
+        clearAllApplicationProperties();
     }
 
     @Override
@@ -244,7 +238,53 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
     }
 
     protected void copyInto(AmqpJmsMessageFacade target) {
-        // TODO - Copy message.
+        target.setDestination(destination);
+        target.setReplyTo(replyTo);
+
+        Message targetMsg = target.getAmqpMessage();
+
+        targetMsg.setDurable(message.isDurable());
+        targetMsg.setDeliveryCount(message.getDeliveryCount());
+        targetMsg.setTtl(message.getTtl());
+        targetMsg.setFirstAcquirer(message.isFirstAcquirer());
+        targetMsg.setPriority(message.getPriority());
+        targetMsg.setMessageId(message.getMessageId());
+        targetMsg.setMessageFormat(message.getMessageFormat());
+        targetMsg.setBody(message.getBody());
+        targetMsg.setUserId(message.getUserId());
+        targetMsg.setGroupId(message.getGroupId());
+        targetMsg.setGroupSequence(message.getGroupSequence());
+        targetMsg.setCreationTime(message.getCreationTime());
+        targetMsg.setSubject(message.getSubject());
+        targetMsg.setExpiryTime(message.getExpiryTime());
+        targetMsg.setReplyToGroupId(message.getReplyToGroupId());
+        targetMsg.setContentEncoding(message.getContentEncoding());
+        targetMsg.setContentType(message.getContentType());
+        targetMsg.setCorrelationId(message.getCorrelationId());
+        targetMsg.setMessageId(message.getMessageId());
+
+        // We don't currently deep copy these as they can't be modified by the client right now.
+        targetMsg.setHeader(message.getHeader());
+        targetMsg.setFooter(message.getFooter());
+
+        // TODO - Need to see how this is implemented in Proton, not clear on the Properties
+        //        vs message set / get of those same properties implementation.
+        // void setProperties(Properties properties);
+
+        if (propertiesMap != null) {
+            target.lazyCreateProperties();
+            target.propertiesMap.putAll(propertiesMap);
+        }
+
+        if (annotationsMap != null) {
+            target.lazyCreateAnnotations();
+            target.annotationsMap.putAll(annotationsMap);
+        }
+
+        if (message.getDeliveryAnnotations() != null) {
+            // TODO - Find the most efficient way to copy these, or don't copy if we would
+            //        not be modifying them.
+        }
     }
 
     @Override


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[3/3] git commit: Add getters and setters for the To and ReplyTo address values from the underlying AMQP message to the message facade and use those in destination helper. Create a new test to start covering the variations of things in AmqpDestinationHe

Posted by ta...@apache.org.
Add getters and setters for the To and ReplyTo address values from the
underlying AMQP message to the message facade and use those in
destination helper.  Create a new test to start covering the variations
of things in AmqpDestinationHelper

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/2943002c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/2943002c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/2943002c

Branch: refs/heads/master
Commit: 2943002c3046b871bd800efda5908663082115a1
Parents: 18adb4e
Author: Timothy Bish <ta...@gmail.com>
Authored: Wed Sep 24 18:06:51 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Wed Sep 24 18:06:51 2014 -0400

----------------------------------------------------------------------
 .../amqp/message/AmqpDestinationHelper.java     |  8 ++--
 .../amqp/message/AmqpJmsMessageFacade.java      | 16 +++++++
 .../amqp/message/AmqpDestinationHelperTest.java | 50 ++++++++++++++++++++
 3 files changed, 70 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/2943002c/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
index 3b84029..d84399d 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
@@ -73,7 +73,7 @@ public class AmqpDestinationHelper {
      */
 
     public JmsDestination getJmsDestination(AmqpJmsMessageFacade message, JmsDestination consumerDestination) {
-        String to = message.getAmqpMessage().getAddress();
+        String to = message.getToAddress();
         String toTypeString = (String) message.getAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
         Set<String> typeSet = null;
 
@@ -85,7 +85,7 @@ public class AmqpDestinationHelper {
     }
 
     public JmsDestination getJmsReplyTo(AmqpJmsMessageFacade message, JmsDestination consumerDestination) {
-        String replyTo = message.getAmqpMessage().getReplyTo();
+        String replyTo = message.getReplyToAddress();
         String replyToTypeString = (String) message.getAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
         Set<String> typeSet = null;
 
@@ -142,7 +142,7 @@ public class AmqpDestinationHelper {
         String address = destination.getName();
         String typeString = toTypeAnnotation(destination);
 
-        message.getAmqpMessage().setAddress(address);
+        message.setToAddress(address);
 
         if (address == null || typeString == null) {
             message.removeAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
@@ -155,7 +155,7 @@ public class AmqpDestinationHelper {
         String replyToAddress = destination.getName();
         String typeString = toTypeAnnotation(destination);
 
-        message.getAmqpMessage().setReplyTo(replyToAddress);
+        message.setReplyToAddress(replyToAddress);
 
         if (replyToAddress == null || typeString == null) {
             message.removeAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/2943002c/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
index 0bb7fb7..d0ee5af 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
@@ -727,6 +727,22 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
         message.setApplicationProperties(null);
     }
 
+    String getToAddress() {
+        return message.getAddress();
+    }
+
+    void setToAddress(String address) {
+        message.setAddress(address);
+    }
+
+    String getReplyToAddress() {
+        return message.getReplyTo();
+    }
+
+    void setReplyToAddress(String address) {
+        this.message.setReplyTo(address);
+    }
+
     private Long getAbsoluteExpiryTime() {
         Long result = null;
         if (message.getProperties() != null) {

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/2943002c/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
new file mode 100644
index 0000000..d03765e
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.jms.provider.amqp.message;
+
+import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING;
+import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
+import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class AmqpDestinationHelperTest {
+
+    private final AmqpDestinationHelper helper = AmqpDestinationHelper.INSTANCE;
+
+    @Test
+    public void testGetJmsDestinationWithNullAddressAndNullConsumerDestReturnsNull() throws Exception {
+        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+        Mockito.when(message.getToAddress()).thenReturn(null);
+        Mockito.when(message.getAnnotation(
+            TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
+
+        assertNull(helper.getJmsDestination(message, null));
+    }
+
+    @Test
+    public void testGetJmsReplyToWithNullAddressAndNullConsumerDestReturnsNull() throws Exception {
+        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+        Mockito.when(message.getToAddress()).thenReturn(null);
+        Mockito.when(message.getAnnotation(
+            REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
+
+        assertNull(helper.getJmsDestination(message, null));
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[2/3] git commit: Cleanup the method names to make them consistent.

Posted by ta...@apache.org.
Cleanup the method names to make them consistent.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/18adb4e7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/18adb4e7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/18adb4e7

Branch: refs/heads/master
Commit: 18adb4e790da069954b416c1ee9705397b9755a0
Parents: 372d5b8
Author: Timothy Bish <ta...@gmail.com>
Authored: Wed Sep 24 17:54:29 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Wed Sep 24 17:54:29 2014 -0400

----------------------------------------------------------------------
 .../qpid/jms/provider/amqp/message/AmqpDestinationHelper.java    | 4 ++--
 .../qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java     | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/18adb4e7/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
index 350aeb4..3b84029 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
@@ -72,7 +72,7 @@ public class AmqpDestinationHelper {
      * returned.
      */
 
-    public JmsDestination buildJmsDestination(AmqpJmsMessageFacade message, JmsDestination consumerDestination) {
+    public JmsDestination getJmsDestination(AmqpJmsMessageFacade message, JmsDestination consumerDestination) {
         String to = message.getAmqpMessage().getAddress();
         String toTypeString = (String) message.getAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
         Set<String> typeSet = null;
@@ -84,7 +84,7 @@ public class AmqpDestinationHelper {
         return createDestination(to, typeSet, consumerDestination, false);
     }
 
-    public JmsDestination buildJmsReplyTo(AmqpJmsMessageFacade message, JmsDestination consumerDestination) {
+    public JmsDestination getJmsReplyTo(AmqpJmsMessageFacade message, JmsDestination consumerDestination) {
         String replyTo = message.getAmqpMessage().getReplyTo();
         String replyToTypeString = (String) message.getAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
         Set<String> typeSet = null;

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/18adb4e7/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
index dff75f6..0bb7fb7 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
@@ -116,8 +116,8 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
             syntheticTTL = System.currentTimeMillis() + ttl;
         }
 
-        this.destination = AmqpDestinationHelper.INSTANCE.buildJmsDestination(this, consumer.getDestination());
-        this.replyTo = AmqpDestinationHelper.INSTANCE.buildJmsReplyTo(this, consumer.getDestination());
+        this.destination = AmqpDestinationHelper.INSTANCE.getJmsDestination(this, consumer.getDestination());
+        this.replyTo = AmqpDestinationHelper.INSTANCE.getJmsReplyTo(this, consumer.getDestination());
     }
 
     /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org