camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r798024 - in /camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms: EndpointMessageListener.java JmsEndpoint.java JmsMessage.java
Date Mon, 27 Jul 2009 04:58:34 GMT
Author: davsclaus
Date: Mon Jul 27 04:58:33 2009
New Revision: 798024

URL: http://svn.apache.org/viewvc?rev=798024&view=rev
Log:
CAMEL-1853: ensuring JmsEndpoint and JmsBinding is always there when needed. Preparing for
CAMEL-1853.

Modified:
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java?rev=798024&r1=798023&r2=798024&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
Mon Jul 27 04:58:33 2009
@@ -137,8 +137,9 @@
 
     public Exchange createExchange(Message message, Destination replyDestination) {
         Exchange exchange = new DefaultExchange(endpoint, endpoint.getExchangePattern());
-        exchange.setProperty(Exchange.BINDING, getBinding());
-        exchange.setIn(new JmsMessage(message));
+        JmsBinding binding = getBinding();
+        exchange.setProperty(Exchange.BINDING, binding);
+        exchange.setIn(new JmsMessage(message, binding));
 
         // lets set to an InOut if we have some kind of reply-to destination
         if (replyDestination != null && !disableReplyTo) {

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java?rev=798024&r1=798023&r2=798024&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
Mon Jul 27 04:58:33 2009
@@ -84,7 +84,8 @@
     }
 
     public JmsEndpoint(String endpointUri, String destinationName, boolean pubSubDomain)
{
-        this(endpointUri, new JmsBinding(), new JmsConfiguration(), destinationName, pubSubDomain);
+        this(endpointUri, null, new JmsConfiguration(), destinationName, pubSubDomain);
+        this.binding = new JmsBinding(this);
     }
 
     /**
@@ -203,7 +204,7 @@
 
     public Exchange createExchange(Message message) {
         Exchange exchange = createExchange(getExchangePattern());
-        exchange.setIn(new JmsMessage(message));
+        exchange.setIn(new JmsMessage(message, getBinding()));
         return exchange;
     }
 

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java?rev=798024&r1=798023&r2=798024&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
Mon Jul 27 04:58:33 2009
@@ -25,7 +25,7 @@
 import javax.jms.Queue;
 import javax.jms.Topic;
 
-import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.RuntimeExchangeException;
 import org.apache.camel.impl.DefaultMessage;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.commons.logging.Log;
@@ -41,15 +41,8 @@
     private Message jmsMessage;
     private JmsBinding binding;
 
-    public JmsMessage() {
-    }
-
-    public JmsMessage(Message jmsMessage) {
-        setJmsMessage(jmsMessage);
-    }
-
     public JmsMessage(Message jmsMessage, JmsBinding binding) {
-        this(jmsMessage);
+        setJmsMessage(jmsMessage);
         setBinding(binding);
     }
 
@@ -90,8 +83,7 @@
 
     public JmsBinding getBinding() {
         if (binding == null) {
-            JmsBinding b = ExchangeHelper.getBinding(getExchange(), JmsBinding.class);
-            return b != null ? b : new JmsBinding();
+            binding = ExchangeHelper.getBinding(getExchange(), JmsBinding.class);
         }
         return binding;
     }
@@ -101,10 +93,12 @@
     }
 
     public void setJmsMessage(Message jmsMessage) {
-        try {
-            setMessageId(jmsMessage.getJMSMessageID());
-        } catch (JMSException e) {
-            LOG.warn("Unable to retrieve JMSMessageID from JMS Message", e);
+        if (jmsMessage != null) {
+            try {
+                setMessageId(jmsMessage.getJMSMessageID());
+            } catch (JMSException e) {
+                LOG.warn("Unable to retrieve JMSMessageID from JMS Message", e);
+            }
         }
         this.jmsMessage = jmsMessage;
     }
@@ -118,7 +112,7 @@
             try {
                 answer = jmsMessage.getObjectProperty(name);
             } catch (JMSException e) {
-                throw new RuntimeCamelException(name, e);
+                throw new RuntimeExchangeException("Unable to retrieve header from JMS Message:
" + name, getExchange(), e);
             }
         }
         if (answer == null) {
@@ -138,7 +132,7 @@
                     answer = JmsMessageHelper.removeJmsProperty(jmsMessage, name);
                 }
             } catch (JMSException e) {
-                throw new RuntimeCamelException(name, e);
+                throw new RuntimeExchangeException("Unable to remove header from JMS Message:
" + name, getExchange(), e);
             }
         }
 
@@ -147,7 +141,7 @@
 
     @Override
     public JmsMessage newInstance() {
-        return new JmsMessage();
+        return new JmsMessage(null, binding);
     }
 
     /**
@@ -184,7 +178,7 @@
             String id = getDestinationAsString(jmsMessage.getJMSDestination()) + jmsMessage.getJMSMessageID();
             return getSanitizedString(id);
         } catch (JMSException e) {
-            throw new RuntimeCamelException("Failed to get JMSMessageID property", e);
+            throw new RuntimeExchangeException("Unable to retrieve JMSMessageID from JMS
Message", getExchange(), e);
         }
     }
 
@@ -210,10 +204,10 @@
             try {
                 return jmsMessage.getJMSMessageID();
             } catch (JMSException e) {
-                throw new RuntimeCamelException("Failed to get JMSMessageID property", e);
+                throw new RuntimeExchangeException("Unable to retrieve JMSMessageID from
JMS Message", getExchange(), e);
             }
         }
         return super.createExchangeId();
-
     }
+
 }



Mime
View raw message