camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r567079 - in /activemq/camel/trunk/components: camel-activemq/src/test/java/org/apache/camel/component/activemq/ camel-jms/src/main/java/org/apache/camel/component/jms/
Date Fri, 17 Aug 2007 16:11:45 GMT
Author: jstrachan
Date: Fri Aug 17 09:11:44 2007
New Revision: 567079

URL: http://svn.apache.org/viewvc?view=rev&rev=567079
Log:
added test case and fix for CAMEL-112

Modified:
    activemq/camel/trunk/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/ActiveMQReplyToHeaderUsingConverterTest.java
    activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
    activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
    activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java

Modified: activemq/camel/trunk/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/ActiveMQReplyToHeaderUsingConverterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/ActiveMQReplyToHeaderUsingConverterTest.java?view=diff&rev=567079&r1=567078&r2=567079
==============================================================================
--- activemq/camel/trunk/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/ActiveMQReplyToHeaderUsingConverterTest.java
(original)
+++ activemq/camel/trunk/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/ActiveMQReplyToHeaderUsingConverterTest.java
Fri Aug 17 09:11:44 2007
@@ -20,6 +20,7 @@
 import org.apache.camel.CamelContext;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
+import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
 import static org.apache.camel.component.activemq.ActiveMQComponent.activeMQComponent;
 import org.apache.camel.component.mock.AssertionClause;
@@ -42,6 +43,7 @@
     protected Object expectedBody = "<time>" + new Date() + "</time>";
     protected String replyQueueName = "queue://test.my.reply.queue";
     protected String correlationID = "ABC-123";
+    protected String groupID = "GROUP-XYZ";
     protected String messageType = getClass().getName();
 
     public void testSendingAMessageFromCamelSetsCustomJmsHeaders() throws Exception {
@@ -53,22 +55,30 @@
         firstMessage.header("JMSCorrelationID").isEqualTo(correlationID);
         firstMessage.header("JMSReplyTo").isEqualTo(ActiveMQConverter.toDestination(replyQueueName));
         firstMessage.header("JMSType").isEqualTo(messageType);
+        firstMessage.header("JMSXGroupID").isEqualTo(groupID);
 
         Map<String, Object> headers = new HashMap<String, Object>();
         headers.put("cheese", 123);
         headers.put("JMSReplyTo", replyQueueName);
         headers.put("JMSCorrelationID", correlationID);
         headers.put("JMSType", messageType);
+        headers.put("JMSXGroupID", groupID);
         template.sendBodyAndHeaders("activemq:test.a", expectedBody, headers);
 
         resultEndpoint.assertIsSatisfied();
 
         List<Exchange> list = resultEndpoint.getReceivedExchanges();
         Exchange exchange = list.get(0);
-        Object replyTo = exchange.getIn().getHeader("JMSReplyTo");
+        Message in = exchange.getIn();
+        Object replyTo = in.getHeader("JMSReplyTo");
         LOG.info("Reply to is: " + replyTo);
         Destination destination = assertIsInstanceOf(Destination.class, replyTo);
         assertEquals("ReplyTo", replyQueueName, destination.toString());
+
+        assertMessageHeader(in, "cheese", 123);
+        assertMessageHeader(in, "JMSCorrelationID", correlationID);
+        assertMessageHeader(in, "JMSType", messageType);
+        assertMessageHeader(in, "JMSXGroupID", groupID);
     }
 
     protected CamelContext createCamelContext() throws Exception {

Modified: activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java?view=diff&rev=567079&r1=567078&r2=567079
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
(original)
+++ activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
Fri Aug 17 09:11:44 2007
@@ -37,6 +37,7 @@
     private Endpoint<E> endpoint;
     private Processor processor;
     private JmsBinding binding;
+    private boolean eagerLoadingOfProperties;
 
     public EndpointMessageListener(Endpoint<E> endpoint, Processor processor) {
         this.endpoint = endpoint;
@@ -50,7 +51,10 @@
                 LOG.debug(endpoint + " receiving JMS message: " + message);
             }
             JmsExchange exchange = createExchange(message);
-            processor.process((E)exchange);
+            if (eagerLoadingOfProperties) {
+                exchange.getIn().getHeaders();
+            }
+            processor.process(exchange);
 
         } catch (Exception e) {
             throw new RuntimeCamelException(e);
@@ -78,5 +82,13 @@
      */
     public void setBinding(JmsBinding binding) {
         this.binding = binding;
+    }
+
+    public boolean isEagerLoadingOfProperties() {
+        return eagerLoadingOfProperties;
+    }
+
+    public void setEagerLoadingOfProperties(boolean eagerLoadingOfProperties) {
+        this.eagerLoadingOfProperties = eagerLoadingOfProperties;
     }
 }

Modified: activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java?view=diff&rev=567079&r1=567078&r2=567079
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
(original)
+++ activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
Fri Aug 17 09:11:44 2007
@@ -95,7 +95,7 @@
             String headerName = entry.getKey();
             Object headerValue = entry.getValue();
             
-            if (headerName.startsWith("JMS")) {
+            if (headerName.startsWith("JMS") && !headerName.startsWith("JMSX")) {
                 if (headerName.equals("JMSCorrelationID")) {
                     jmsMessage.setJMSCorrelationID(ExchangeHelper.convertToType(exchange,
String.class, headerValue));
                 }

Modified: activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java?view=diff&rev=567079&r1=567078&r2=567079
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
(original)
+++ activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
Fri Aug 17 09:11:44 2007
@@ -122,6 +122,10 @@
                 map.put("JMSReplyTo", jmsMessage.getJMSReplyTo());
                 map.put("JMSTimestamp", jmsMessage.getJMSTimestamp());
                 map.put("JMSType", jmsMessage.getJMSType());
+
+                // TODO this works around a bug in the ActiveMQ property handling
+                map.put("JMSXGroupID", jmsMessage.getStringProperty("JMSXGroupID"));
+
             }
             catch (JMSException e) {
                 throw new MessageJMSPropertyAccessException(e);



Mime
View raw message