camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r965392 - in /camel/trunk/components/camel-jms/src: main/java/org/apache/camel/component/jms/ test/java/org/apache/camel/component/jms/
Date Mon, 19 Jul 2010 09:11:48 GMT
Author: davsclaus
Date: Mon Jul 19 09:11:47 2010
New Revision: 965392

URL: http://svn.apache.org/viewvc?rev=965392&view=rev
Log:
CAMEL-2962: JmsProducer now checks the disableReplyTo endpoint configuration and if enabled
will force to use InOnly MEP style when sending.

Added:
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsConsumeTemplateTest.java
  (with props)
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java
  (with props)
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java
  (with props)
Modified:
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java?rev=965392&r1=965391&r2=965392&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
Mon Jul 19 09:11:47 2010
@@ -142,7 +142,7 @@ public class JmsProducer extends Default
     }
 
     public void process(final Exchange exchange) {
-        if (exchange.getPattern().isOutCapable()) {
+        if (!endpoint.isDisableReplyTo() && exchange.getPattern().isOutCapable())
{
             // in out requires a bit more work than in only
             processInOut(exchange);
         } else {

Added: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsConsumeTemplateTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsConsumeTemplateTest.java?rev=965392&view=auto
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsConsumeTemplateTest.java
(added)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsConsumeTemplateTest.java
Mon Jul 19 09:11:47 2010
@@ -0,0 +1,57 @@
+/**
+ * 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.camel.component.jms;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+/**
+ * @version $Revision$
+ */
+public class JmsConsumeTemplateTest extends CamelTestSupport {
+
+    @Test
+    public void testConsumeTemplate() throws Exception {
+        String url = "activemq:queue:foo";
+        template.sendBody(url, "Hello World");
+
+        Object out = consumer.receiveBody(url, 5000);
+        assertEquals("Hello World", out);
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        // must be persistent so the consumer can receive the message as we receive AFTER
the message
+        // has been published
+        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=true");
+        camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+
+        return camelContext;
+    }
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsConsumeTemplateTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsConsumeTemplateTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java?rev=965392&view=auto
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java
(added)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java
Mon Jul 19 09:11:47 2010
@@ -0,0 +1,76 @@
+/**
+ * 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.camel.component.jms;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+/**
+ * @version $Revision$
+ */
+public class JmsDeadLetterChannelInOutTest extends CamelTestSupport {
+
+    @Test
+    public void testJmsDLCInOut() throws Exception {
+        Exchange out = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                // use InOut
+                exchange.setPattern(ExchangePattern.InOut);
+                exchange.getIn().setBody("Hello World");
+            }
+        });
+        assertNotNull(out);
+
+        // should be in DLQ
+        Object dead = consumer.receiveBody("activemq:queue:error", 5000);
+        assertEquals("Hello World", dead);
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        // must be persistent so the consumer can receive the message as we receive AFTER
the message
+        // has been published
+        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=true");
+        camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+
+        return camelContext;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("activemq:queue:error?disableReplyTo=true"));
+
+                from("direct:start").throwException(new IllegalArgumentException("Damn"));
+            }
+        };
+    }
+}
+

Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java?rev=965392&view=auto
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java
(added)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java
Mon Jul 19 09:11:47 2010
@@ -0,0 +1,57 @@
+/**
+ * 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.camel.component.jms;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+/**
+ * @version $Revision$
+ */
+public class JmsProducerDisableReplyToTest extends CamelTestSupport {
+
+    @Test
+    public void testProducerDisableReplyTo() throws Exception {
+        String url = "activemq:queue:foo?disableReplyTo=true";
+        template.requestBody(url, "Hello World");
+
+        Object out = consumer.receiveBody(url, 5000);
+        assertEquals("Hello World", out);
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        // must be persistent so the consumer can receive the message as we receive AFTER
the message
+        // has been published
+        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=true");
+        camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+
+        return camelContext;
+    }
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message