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 2009/04/05 08:52:46 UTC
svn commit: r762047 - in /camel/trunk/components/camel-jms/src:
main/java/org/apache/camel/component/jms/JmsProducer.java
test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java
Author: davsclaus
Date: Sun Apr 5 06:52:46 2009
New Revision: 762047
URL: http://svn.apache.org/viewvc?rev=762047&view=rev
Log:
CAMEL-1461: Applied patch with thanks to Marat, for patiently explaining the issue and providing this great patch.
Added:
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.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=762047&r1=762046&r2=762047&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 Sun Apr 5 06:52:46 2009
@@ -282,7 +282,6 @@
String to = destinationName != null ? destinationName : "" + destination;
LOG.warn("Disabling JMSReplyTo as this Exchange is not OUT capable: " + exchange + " with destination: " + to);
exchange.getIn().setHeader("JMSReplyTo", null);
- exchange.getIn().setHeader("JMSCorrelationID", null);
}
MessageCreator messageCreator = new MessageCreator() {
Added: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java?rev=762047&view=auto
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java (added)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java Sun Apr 5 06:52:46 2009
@@ -0,0 +1,120 @@
+/**
+ * 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.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
+
+public class JmsRouteWithInOnlyAndMultipleAcksTest extends ContextTestSupport {
+
+ protected String componentName = "amq";
+
+ public void testSendOrderWithMultipleAcks() throws Exception {
+ MockEndpoint inbox = getMockEndpoint("mock:inbox");
+ inbox.expectedBodiesReceived("Camel in Action");
+
+ String orderId = "1";
+ MockEndpoint notifCollector = getMockEndpoint("mock:orderNotificationAckCollector");
+ notifCollector.expectedMessageCount(2);
+ notifCollector.expectedHeaderReceived("JMSCorrelationID", orderId);
+ notifCollector.setResultWaitTime(10000);
+
+ Object out = template.requestBodyAndHeader("amq:queue:inbox", "Camel in Action", "JMSCorrelationID", orderId);
+ assertEquals("OK: Camel in Action", out);
+
+ assertMockEndpointsSatisfied();
+ }
+
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry jndi = super.createRegistry();
+ jndi.bind("orderService", new MyOrderServiceBean());
+ jndi.bind("orderServiceNotificationWithAck-1", new MyOrderServiceNotificationWithAckBean("1"));
+ jndi.bind("orderServiceNotificationWithAck-2", new MyOrderServiceNotificationWithAckBean("2"));
+ return jndi;
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+
+ ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
+ "vm://localhost?broker.persistent=false");
+ camelContext.addComponent(componentName,
+ jmsComponentClientAcknowledge(connectionFactory));
+
+ return camelContext;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // this route picks up an order request
+ // send out a one way notification to multiple
+ // topic subscribers, lets a bean handle
+ // the order and then delivers a reply back to
+ // the original order request initiator
+ from("amq:queue:inbox")
+ .to("mock:inbox")
+ .inOnly("amq:topic:orderServiceNotification")
+ .beanRef("orderService", "handleOrder");
+
+ // this route collects an order request notification
+ // and sends back an acknowledgment back to a queue
+ from("amq:topic:orderServiceNotification")
+ .beanRef("orderServiceNotificationWithAck-1", "handleOrderNotificationWithAck")
+ .to("amq:queue:orderServiceNotificationAck");
+
+ // this route collects an order request notification
+ // and sends back an acknowledgment back to a queue
+ from("amq:topic:orderServiceNotification")
+ .beanRef("orderServiceNotificationWithAck-2", "handleOrderNotificationWithAck")
+ .to("amq:queue:orderServiceNotificationAck");
+
+ // this route collects all order notifications acknowledgments
+ from("amq:queue:orderServiceNotificationAck")
+ .to("mock:orderNotificationAckCollector");
+ }
+ };
+ }
+
+ public static class MyOrderServiceBean {
+ public String handleOrder(String body) {
+ return "OK: " + body;
+ }
+ }
+
+ public static class MyOrderServiceNotificationWithAckBean {
+ private String id;
+
+ public MyOrderServiceNotificationWithAckBean(String id) {
+ this.id = id;
+ }
+ public String handleOrder(String body) {
+ return "Ack-" + id + ":" + body;
+ }
+ }
+}
Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteWithInOnlyAndMultipleAcksTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date