You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/10/04 14:49:27 UTC

[1/2] git commit: Added unit test based on user forum issue

Updated Branches:
  refs/heads/camel-2.12.x 70e1c9b02 -> 553e9e651
  refs/heads/master 6b2101693 -> 75c9be37e


Added unit test based on user forum issue


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

Branch: refs/heads/master
Commit: 75c9be37e7a85abfc4e3ee53fe9323009232a23b
Parents: 6b21016
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Oct 4 14:48:54 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Oct 4 14:48:54 2013 +0200

----------------------------------------------------------------------
 .../component/jms/reply/QueueReplyManager.java  |  3 +-
 .../jms/issues/JmsInOutExclusiveTopicTest.java  | 82 ++++++++++++++++++++
 2 files changed, 84 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/75c9be37/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/QueueReplyManager.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/QueueReplyManager.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/QueueReplyManager.java
index c18a892..e8675b9 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/QueueReplyManager.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/QueueReplyManager.java
@@ -80,7 +80,8 @@ public class QueueReplyManager extends ReplyManagerSupport {
             // we could not correlate the received reply message to a matching request and therefore
             // we cannot continue routing the unknown message
             // log a warn and then ignore the message
-            log.warn("Reply received for unknown correlationID [{}]. The message will be ignored: {}", correlationID, message);
+            log.warn("Reply received for unknown correlationID [{}] on reply destination [{}]. Current correlation map size: {}. The message will be ignored: {}",
+                    new Object[]{correlationID, replyTo, correlation.size(), message});
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/75c9be37/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutExclusiveTopicTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutExclusiveTopicTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutExclusiveTopicTest.java
new file mode 100644
index 0000000..59c2ac9
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutExclusiveTopicTest.java
@@ -0,0 +1,82 @@
+/**
+ * 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.issues;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.CamelJmsTestHelper;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+/**
+ * @version 
+ */
+public class JmsInOutExclusiveTopicTest extends CamelTestSupport {
+
+    @Test
+    public void testJmsInOutExclusiveTopicTest() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel");
+
+        String out = template.requestBody("direct:start", "Camel", String.class);
+        assertEquals("Bye Camel", out);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+        return camelContext;
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("activemq:topic:news?replyToType=Exclusive&replyTo=queue:back")
+                    .to("mock:result");
+
+                from("activemq:topic:news?disableReplyTo=true")
+                        .transform(body().prepend("Bye "))
+                        .process(new Processor() {
+                            @Override
+                            public void process(Exchange exchange) throws Exception {
+                                String replyTo = exchange.getIn().getHeader("JMSReplyTo", String.class);
+                                String cid = exchange.getIn().getHeader("JMSCorrelationID", String.class);
+
+                                log.info("ReplyTo: {}", replyTo);
+                                log.info("CorrelationID: {}", cid);
+                                if (replyTo != null && cid != null) {
+                                    // wait a bit before sending back
+                                    Thread.sleep(1000);
+                                    log.info("Sending back reply message on {}", replyTo);
+                                    template.sendBodyAndHeader("activemq:" + replyTo, exchange.getIn().getBody(), "JMSCorrelationID", cid);
+                                }
+                            }
+                        });
+            }
+        };
+    }
+
+}


[2/2] git commit: Added unit test based on user forum issue

Posted by da...@apache.org.
Added unit test based on user forum issue


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

Branch: refs/heads/camel-2.12.x
Commit: 553e9e651438700b9bbfde65bbf6b0eb08f6c49a
Parents: 70e1c9b
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Oct 4 14:48:54 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Oct 4 14:49:10 2013 +0200

----------------------------------------------------------------------
 .../component/jms/reply/QueueReplyManager.java  |  3 +-
 .../jms/issues/JmsInOutExclusiveTopicTest.java  | 82 ++++++++++++++++++++
 2 files changed, 84 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/553e9e65/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/QueueReplyManager.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/QueueReplyManager.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/QueueReplyManager.java
index c18a892..e8675b9 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/QueueReplyManager.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/QueueReplyManager.java
@@ -80,7 +80,8 @@ public class QueueReplyManager extends ReplyManagerSupport {
             // we could not correlate the received reply message to a matching request and therefore
             // we cannot continue routing the unknown message
             // log a warn and then ignore the message
-            log.warn("Reply received for unknown correlationID [{}]. The message will be ignored: {}", correlationID, message);
+            log.warn("Reply received for unknown correlationID [{}] on reply destination [{}]. Current correlation map size: {}. The message will be ignored: {}",
+                    new Object[]{correlationID, replyTo, correlation.size(), message});
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/553e9e65/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutExclusiveTopicTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutExclusiveTopicTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutExclusiveTopicTest.java
new file mode 100644
index 0000000..59c2ac9
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutExclusiveTopicTest.java
@@ -0,0 +1,82 @@
+/**
+ * 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.issues;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.CamelJmsTestHelper;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+/**
+ * @version 
+ */
+public class JmsInOutExclusiveTopicTest extends CamelTestSupport {
+
+    @Test
+    public void testJmsInOutExclusiveTopicTest() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel");
+
+        String out = template.requestBody("direct:start", "Camel", String.class);
+        assertEquals("Bye Camel", out);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+        return camelContext;
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("activemq:topic:news?replyToType=Exclusive&replyTo=queue:back")
+                    .to("mock:result");
+
+                from("activemq:topic:news?disableReplyTo=true")
+                        .transform(body().prepend("Bye "))
+                        .process(new Processor() {
+                            @Override
+                            public void process(Exchange exchange) throws Exception {
+                                String replyTo = exchange.getIn().getHeader("JMSReplyTo", String.class);
+                                String cid = exchange.getIn().getHeader("JMSCorrelationID", String.class);
+
+                                log.info("ReplyTo: {}", replyTo);
+                                log.info("CorrelationID: {}", cid);
+                                if (replyTo != null && cid != null) {
+                                    // wait a bit before sending back
+                                    Thread.sleep(1000);
+                                    log.info("Sending back reply message on {}", replyTo);
+                                    template.sendBodyAndHeader("activemq:" + replyTo, exchange.getIn().getBody(), "JMSCorrelationID", cid);
+                                }
+                            }
+                        });
+            }
+        };
+    }
+
+}