Return-Path: X-Original-To: apmail-camel-dev-archive@www.apache.org Delivered-To: apmail-camel-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A08D4DD7B for ; Thu, 20 Sep 2012 06:24:24 +0000 (UTC) Received: (qmail 40620 invoked by uid 500); 20 Sep 2012 06:24:24 -0000 Delivered-To: apmail-camel-dev-archive@camel.apache.org Received: (qmail 40521 invoked by uid 500); 20 Sep 2012 06:24:23 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 40509 invoked by uid 99); 20 Sep 2012 06:24:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Sep 2012 06:24:23 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of christian.mueller@gmail.com designates 209.85.216.173 as permitted sender) Received: from [209.85.216.173] (HELO mail-qc0-f173.google.com) (209.85.216.173) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Sep 2012 06:24:15 +0000 Received: by qcab12 with SMTP id b12so1868531qca.32 for ; Wed, 19 Sep 2012 23:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=2AGS8r2Rk2zvzmnyViK0404oja/hZI9gtz0yLhnASwE=; b=Ga0WEUc9uax7uN/FPtdcxIirOcSTlWTMrsYkJKSuR/CxaoKjyq4XAgoW0+RlRBIFhT BxCUMptVq2gMVdwXdKa0rYFQOSuhL50wEnXHP0ADatziMh2rpgn+qfPRM1WItGRk+Faz vFT2d2hCFFiohlID7edH6vA5sLesRu/vUvnj2uHndm4xardluRoIc0HwFGNulLnG1uSJ Mq2bzGb0oSxXIgC5i6vGgHjk9qVESh5arSDhMlSbBXmwfKS8Ug1JXG8gj1idnDAhv8le ll3Eo/lXU7dV7MAoRj5Cc297ABvRsqypMJkfK2l7/ZOaVawDASmMZ0fBQ2F4DFc4wfaw CaaA== MIME-Version: 1.0 Received: by 10.224.59.129 with SMTP id l1mr2315448qah.97.1348122234003; Wed, 19 Sep 2012 23:23:54 -0700 (PDT) Received: by 10.49.63.9 with HTTP; Wed, 19 Sep 2012 23:23:53 -0700 (PDT) Received: by 10.49.63.9 with HTTP; Wed, 19 Sep 2012 23:23:53 -0700 (PDT) In-Reply-To: <20120919230241.5AED423888E3@eris.apache.org> References: <20120919230241.5AED423888E3@eris.apache.org> Date: Thu, 20 Sep 2012 08:23:53 +0200 Message-ID: Subject: Re: svn commit: r1387808 - in /camel/trunk/components/camel-jms/src: main/java/org/apache/camel/component/jms/ test/java/org/apache/camel/component/jms/issues/ From: =?ISO-8859-1?Q?Christian_M=FCller?= To: dev@camel.apache.org Content-Type: multipart/alternative; boundary=20cf3074b08cdf20b104ca1c2ad6 --20cf3074b08cdf20b104ca1c2ad6 Content-Type: text/plain; charset=ISO-8859-1 Rauls first commit! Sent from a mobile device Am 20.09.2012 01:03 schrieb : > Author: raulk > Date: Wed Sep 19 23:02:40 2012 > New Revision: 1387808 > > URL: http://svn.apache.org/viewvc?rev=1387808&view=rev > Log: > CAMEL-5390: Option to assign unique correlation ID to JMS messages. Fixed. > > Added: > > camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutParallelTest.java > > camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutRepeatedInvocationsTest.java > 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=1387808&r1=1387807&r2=1387808&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 > Wed Sep 19 23:02:40 2012 > @@ -52,6 +52,7 @@ import static org.apache.camel.component > */ > public class JmsProducer extends DefaultAsyncProducer { > private static final transient Logger LOG = > LoggerFactory.getLogger(JmsProducer.class); > + private static final String GENERATED_CORRELATION_ID_PREFIX = > "Camel-"; > private final JmsEndpoint endpoint; > private final AtomicBoolean started = new AtomicBoolean(false); > private JmsOperations inOnlyTemplate; > @@ -175,10 +176,13 @@ public class JmsProducer extends Default > final ValueHolder sentCallback = new > ValueHolder(messageSentCallback); > > final String originalCorrelationId = > in.getHeader("JMSCorrelationID", String.class); > - if (ObjectHelper.isEmpty(originalCorrelationId) && > !msgIdAsCorrId) { > - in.setHeader("JMSCorrelationID", > getUuidGenerator().generateUuid()); > + boolean generateFreshCorrId = > (ObjectHelper.isEmpty(originalCorrelationId) && !msgIdAsCorrId) > + || (originalCorrelationId != null && > originalCorrelationId.startsWith(GENERATED_CORRELATION_ID_PREFIX)); > + if (generateFreshCorrId) { > + // we append the 'Camel-' prefix to know it was generated by > us > + in.setHeader("JMSCorrelationID", > GENERATED_CORRELATION_ID_PREFIX + getUuidGenerator().generateUuid()); > } > - > + > MessageCreator messageCreator = new MessageCreator() { > public Message createMessage(Session session) throws > JMSException { > Message answer = > endpoint.getBinding().makeJmsMessage(exchange, in, session, null); > > Added: > camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutParallelTest.java > URL: > http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutParallelTest.java?rev=1387808&view=auto > > ============================================================================== > --- > camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutParallelTest.java > (added) > +++ > camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutParallelTest.java > Wed Sep 19 23:02:40 2012 > @@ -0,0 +1,78 @@ > +/** > + * 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.builder.RouteBuilder; > +import org.apache.camel.component.jms.CamelJmsTestHelper; > +import org.apache.camel.component.mock.MockEndpoint; > +import org.apache.camel.test.junit4.CamelTestSupport; > +import org.junit.Test; > + > +import static > org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge; > + > +/** > + * @version > + */ > +public class JmsInOutParallelTest extends CamelTestSupport { > + > + @Test > + public void testInOutParallel() throws Exception { > + MockEndpoint mock = getMockEndpoint("mock:received"); > + mock.setAssertPeriod(2000); > + mock.expectedMessageCount(5); > + String outPayload = template.requestBody("direct:test", "test", > String.class); > + assertEquals("Fully done", outPayload); > + mock.assertIsSatisfied(); > + } > + > + 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:test") > + .setBody(constant("1,2,3,4,5")) > + .inOut("activemq:queue:test1?requestTimeout=2000") > + .split().tokenize(",").parallelProcessing() > + .inOut("activemq:queue:test2?requestTimeout=2000") > + .to("mock:received") > + .end() > + .setBody(constant("Fully done")) > + .log("Finished"); > + > + from("activemq:queue:test1") > + .log("Received on queue test1"); > + > + from("activemq:queue:test2") > + .log("Received on queue test2") > + .setBody(constant("Some reply")) > + .delay(constant(100)); > + > + } > + }; > + } > + > +} > > Added: > camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutRepeatedInvocationsTest.java > URL: > http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutRepeatedInvocationsTest.java?rev=1387808&view=auto > > ============================================================================== > --- > camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutRepeatedInvocationsTest.java > (added) > +++ > camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutRepeatedInvocationsTest.java > Wed Sep 19 23:02:40 2012 > @@ -0,0 +1,70 @@ > +/** > + * 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.builder.RouteBuilder; > +import org.apache.camel.component.jms.CamelJmsTestHelper; > +import org.apache.camel.component.mock.MockEndpoint; > +import org.apache.camel.test.junit4.CamelTestSupport; > +import org.junit.Test; > + > +import static > org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge; > + > +/** > + * @version > + */ > +public class JmsInOutRepeatedInvocationsTest extends CamelTestSupport { > + > + @Test > + public void testInOutRepeatSequentialInvocations() throws Exception { > + MockEndpoint mock = getMockEndpoint("mock:finished"); > + mock.setAssertPeriod(2000); > + mock.expectedMessageCount(1); > + String outPayload = template.requestBody("direct:test", "test", > String.class); > + assertEquals("Some reply", outPayload); > + mock.assertIsSatisfied(); > + } > + > + 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:test") > + .inOut("activemq:queue:test1?requestTimeout=200") > + .inOut("activemq:queue:test1?requestTimeout=200") > + .inOut("activemq:queue:test1?requestTimeout=200") > + .to("mock:finished"); > + > + from("activemq:queue:test1") > + .log("Received on queue test1") > + .setBody().constant("Some reply"); > + > + } > + }; > + } > + > +} > > > --20cf3074b08cdf20b104ca1c2ad6--