activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6444
Date Thu, 06 Oct 2016 18:20:15 GMT
Repository: activemq
Updated Branches:
  refs/heads/master b6759b33d -> baef8f8ec


https://issues.apache.org/jira/browse/AMQ-6444

Remove some unneeded instance of checks and used cached values where
possible.

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

Branch: refs/heads/master
Commit: baef8f8ec20ed3057895f6ec1e02ca6ea75a33a1
Parents: b6759b3
Author: Timothy Bish <tabish121@gmail.com>
Authored: Thu Oct 6 14:19:54 2016 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Thu Oct 6 14:20:03 2016 -0400

----------------------------------------------------------------------
 .../message/JMSMappingOutboundTransformer.java  | 30 +++++++++-----------
 .../JMSTransformationSpeedComparisonTest.java   |  2 +-
 2 files changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/baef8f8e/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/message/JMSMappingOutboundTransformer.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/message/JMSMappingOutboundTransformer.java
b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/message/JMSMappingOutboundTransformer.java
index 69039ea..5b22099 100644
--- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/message/JMSMappingOutboundTransformer.java
+++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/message/JMSMappingOutboundTransformer.java
@@ -54,15 +54,10 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageEOFException;
-import javax.jms.Queue;
-import javax.jms.TemporaryQueue;
-import javax.jms.TemporaryTopic;
 import javax.jms.TextMessage;
-import javax.jms.Topic;
 
 import org.apache.activemq.command.ActiveMQBytesMessage;
 import org.apache.activemq.command.ActiveMQDestination;
@@ -71,6 +66,7 @@ import org.apache.activemq.command.ActiveMQMessage;
 import org.apache.activemq.command.ActiveMQObjectMessage;
 import org.apache.activemq.command.ActiveMQStreamMessage;
 import org.apache.activemq.command.ActiveMQTextMessage;
+import org.apache.activemq.command.CommandTypes;
 import org.apache.activemq.command.MessageId;
 import org.apache.activemq.transport.amqp.AmqpProtocolException;
 import org.apache.activemq.util.JMSExceptionSupport;
@@ -140,7 +136,7 @@ public class JMSMappingOutboundTransformer implements OutboundTransformer
{
             if (header == null) {
                 header = new Header();
             }
-            header.setPriority(new UnsignedByte(priority));
+            header.setPriority(UnsignedByte.valueOf(priority));
         }
         String type = message.getType();
         if (type != null) {
@@ -376,7 +372,9 @@ public class JMSMappingOutboundTransformer implements OutboundTransformer
{
             // Ignore and stick with UNKNOWN
         }
 
-        if (message instanceof ActiveMQBytesMessage) {
+        int messageType = message.getDataStructureType();
+
+        if (messageType == CommandTypes.ACTIVEMQ_BYTES_MESSAGE) {
             Binary payload = getBinaryFromMessageBody((ActiveMQBytesMessage) message);
 
             if (payload == null) {
@@ -395,7 +393,7 @@ public class JMSMappingOutboundTransformer implements OutboundTransformer
{
                     body = new Data(payload);
                     break;
             }
-        } else if (message instanceof ActiveMQTextMessage) {
+        } else if (messageType == CommandTypes.ACTIVEMQ_TEXT_MESSAGE) {
             switch (orignalEncoding) {
                 case AMQP_NULL:
                     break;
@@ -408,9 +406,9 @@ public class JMSMappingOutboundTransformer implements OutboundTransformer
{
                     body = new AmqpValue(((TextMessage) message).getText());
                     break;
             }
-        } else if (message instanceof ActiveMQMapMessage) {
+        } else if (messageType == CommandTypes.ACTIVEMQ_MAP_MESSAGE) {
             body = new AmqpValue(getMapFromMessageBody((ActiveMQMapMessage) message));
-        } else if (message instanceof ActiveMQStreamMessage) {
+        } else if (messageType == CommandTypes.ACTIVEMQ_STREAM_MESSAGE) {
             ArrayList<Object> list = new ArrayList<Object>();
             final ActiveMQStreamMessage m = (ActiveMQStreamMessage) message;
             try {
@@ -430,7 +428,7 @@ public class JMSMappingOutboundTransformer implements OutboundTransformer
{
                     body = new AmqpValue(list);
                     break;
             }
-        } else if (message instanceof ActiveMQObjectMessage) {
+        } else if (messageType == CommandTypes.ACTIVEMQ_OBJECT_MESSAGE) {
             Binary payload = getBinaryFromMessageBody((ActiveMQObjectMessage) message);
 
             if (payload == null) {
@@ -461,15 +459,15 @@ public class JMSMappingOutboundTransformer implements OutboundTransformer
{
         return body;
     }
 
-    private static byte destinationType(Destination destination) {
-        if (destination instanceof Queue) {
-            if (destination instanceof TemporaryQueue) {
+    private static byte destinationType(ActiveMQDestination destination) {
+        if (destination.isQueue()) {
+            if (destination.isTemporary()) {
                 return TEMP_QUEUE_TYPE;
             } else {
                 return QUEUE_TYPE;
             }
-        } else if (destination instanceof Topic) {
-            if (destination instanceof TemporaryTopic) {
+        } else if (destination.isTopic()) {
+            if (destination.isTemporary()) {
                 return TEMP_TOPIC_TYPE;
             } else {
                 return TOPIC_TYPE;

http://git-wip-us.apache.org/repos/asf/activemq/blob/baef8f8e/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/message/JMSTransformationSpeedComparisonTest.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/message/JMSTransformationSpeedComparisonTest.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/message/JMSTransformationSpeedComparisonTest.java
index cd93af7..836ec36 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/message/JMSTransformationSpeedComparisonTest.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/message/JMSTransformationSpeedComparisonTest.java
@@ -60,7 +60,7 @@ public class JMSTransformationSpeedComparisonTest {
 
     private final String transformer;
 
-    private final int WARM_CYCLES = 1000;
+    private final int WARM_CYCLES = 10000;
     private final int PROFILE_CYCLES = 1000000;
 
     public JMSTransformationSpeedComparisonTest(String transformer) {


Mime
View raw message