Return-Path: Delivered-To: apmail-activemq-camel-user-archive@locus.apache.org Received: (qmail 93290 invoked from network); 30 Sep 2008 19:41:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Sep 2008 19:41:17 -0000 Received: (qmail 98808 invoked by uid 500); 30 Sep 2008 19:41:15 -0000 Delivered-To: apmail-activemq-camel-user-archive@activemq.apache.org Received: (qmail 98678 invoked by uid 500); 30 Sep 2008 19:41:15 -0000 Mailing-List: contact camel-user-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-user@activemq.apache.org Delivered-To: mailing list camel-user@activemq.apache.org Received: (qmail 98667 invoked by uid 99); 30 Sep 2008 19:41:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Sep 2008 12:41:15 -0700 X-ASF-Spam-Status: No, hits=3.2 required=10.0 tests=HTML_MESSAGE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.217.15] (HELO mail-gx0-f15.google.com) (209.85.217.15) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Sep 2008 19:40:12 +0000 Received: by gxk8 with SMTP id 8so11782441gxk.14 for ; Tue, 30 Sep 2008 12:39:45 -0700 (PDT) Received: by 10.142.193.13 with SMTP id q13mr3026968wff.103.1222803584219; Tue, 30 Sep 2008 12:39:44 -0700 (PDT) Received: by 10.143.14.8 with HTTP; Tue, 30 Sep 2008 12:39:44 -0700 (PDT) Message-ID: <56b1dfc30809301239l792c9a06n51cbb959abe1ef03@mail.gmail.com> Date: Tue, 30 Sep 2008 12:39:44 -0700 From: "Mick Knutson" To: camel-user@activemq.apache.org Subject: Re: issue routing Exchange to custom method in Processor In-Reply-To: <4C1FB9C00D24A140906239533638C4D205716D4D@EXVS04.exserver.dk> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_51148_15069580.1222803584202" References: <56b1dfc30809301015s7690e027vaa17d8209f0938e0@mail.gmail.com> <4C1FB9C00D24A140906239533638C4D205716D4D@EXVS04.exserver.dk> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_51148_15069580.1222803584202 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I tried this new method as your instructions first with 1.4 *New Method:* *protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { from("direct:start") .errorHandler(deadLetterChannel("mock:error").maximumRedeliveries(1)) .process(new Processor() { public void process(Exchange exchange) throws Exception { String body = exchange.getIn().getBody(String.class); if ("Boom".equals(body)) { throw new IllegalArgumentException("Forced exception by unit test"); } exchange.getIn().setBody("Bye World"); } }) .to("mock:result"); } }; } @Test(groups = {"functional"}) public void testError() throws Exception { camelContext.addRoutes(createRouteBuilder()); log.info("----------------------------------------------------"); log.info("----------------------------------------------------"); log.info("----------------------------------------------------"); log.info("----------------------------------------------------"); log.info("----------------------------------------------------"); MockEndpoint error = getMockEndpoint("mock:error"); MockEndpoint result = getMockEndpoint("mock:result"); error.expectedMessageCount(1); result.expectedMessageCount(0); //try { producerTemplate.sendBody("direct:start", "Boom"); Assert.fail("Should have thrown a RuntimeCamelException"); //} catch (RuntimeCamelException e) { //assertIsInstanceOf(IllegalArgumentException.class, e.getCause()); //} MockEndpoint.assertIsSatisfied(error, result); log.info("----------------------------------------------------"); log.info("----------------------------------------------------"); log.info("----------------------------------------------------"); log.info("----------------------------------------------------"); log.info("----------------------------------------------------"); } * *My TestNG results:* * * *Console Output:* *[myproject] DEBUG [main] DefaultComponent.createEndpoint(77) | Creating endpoint uri=[direct:start], path=[start], parameters=[{}] [myproject] DEBUG [main] DefaultCamelContext.getEndpoint(281) | direct:start converted to endpoint: Endpoint[direct:start] by component: org.apache.ca mel.component.direct.DirectComponent@b49b19 [myproject] DEBUG [main] DefaultInstrumentationAgent.registerMBeanWithServer(247) | Registered MBean with objectname: org.apache.camel:context=mickknu tson/camel,type=endpoint,component=direct,name=start [myproject] DEBUG [main] DefaultInstrumentationAgent.registerMBeanWithServer(247) | Registered MBean with objectname: org.apache.camel:context=mickknu tson/camel,route=[direct]start,type=processor,nodeid=process4,name="process[com.servepath.changerequest.ChangeRequestTest$1$1@132be10 ]" [myproject] DEBUG [main] DefaultInstrumentationAgent.registerMBeanWithServer(247) | Registered MBean with objectname: org.apache.camel:context=mickknu tson/camel,route=[direct]start,type=processor,nodeid=to5,name="To[mock:result]" [myproject] DEBUG [main] DefaultComponent.createEndpoint(77) | Creating endpoint uri=[mock:result], path=[result], parameters=[{}] [myproject] DEBUG [main] DefaultCamelContext.getEndpoint(281) | mock:result converted to endpoint: Endpoint[mock:result] by component: org.apache.came l.component.mock.MockComponent@6691da [myproject] DEBUG [main] DefaultInstrumentationAgent.registerMBeanWithServer(247) | Registered MBean with objectname: org.apache.camel:context=mickknu tson/camel,type=endpoint,component=mock,name=result [myproject] DEBUG [main] DefaultInstrumentationAgent.registerMBeanWithServer(247) | Registered MBean with objectname: org.apache.camel:context=mickknu tson/camel,route=[direct]start,type=route,name=[direct]start [myproject] DEBUG [main] DefaultCamelContext.addRoutes(354) | Adding routes from: Routes: [Route[ [From[direct:start]] -> [Interceptor[Delegate(Pipeli ne[DeadLetterChannel[Delegate(com.servepath.changerequest.ChangeRequestTest$1$1@132be10), sendTo(Endpoint[mock:error]), RedeliveryPolicy[maximumRedeli veries=1, initialRedeliveryDelay=1000, maximumRedeliveryDelay=60000, useExponentialBackOff=false, backOffMultiplier=2.0, useCollisionAvoidance=false, collisionAvoidanceFactor=0.15]], DeadLetterChannel[Delegate(sendTo(Endpoint[mock:result])), sendTo(Endpoint[mock:error]), RedeliveryPolicy[maximumRede liveries=1, initialRedeliveryDelay=1000, maximumRedeliveryDelay=60000, useExponentialBackOff=false, backOffMultiplier=2.0, useCollisionAvoidance=false , collisionAvoidanceFactor=0.15]]])]]]] routes: [] [myproject] INFO [main] ChangeRequestTest.testError(60) | ---------------------------------------------------- [myproject] INFO [main] ChangeRequestTest.testError(61) | ---------------------------------------------------- [myproject] INFO [main] ChangeRequestTest.testError(62) | ---------------------------------------------------- [myproject] INFO [main] ChangeRequestTest.testError(63) | ---------------------------------------------------- [myproject] INFO [main] ChangeRequestTest.testError(64) | ---------------------------------------------------- [myproject] DEBUG [main] ProducerCache.sendExchange(149) | >>>> Endpoint[direct:start] Exchange[Message: Boom] [myproject] ERROR [main] DeadLetterChannel.log(188) | Failed delivery for exchangeId: ID-mickknutson/1230-1222803205187/0-0. On delivery attempt: 0 ca ught: java.lang.IllegalArgumentException: Forced exception by unit test java.lang.IllegalArgumentException: Forced exception by unit test at com.servepath.changerequest.ChangeRequestTest$1$1.process(ChangeRequestTest.java:45) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:75) at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:174) at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:96) at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) at org.apache.camel.processor.Pipeline.process(Pipeline.java:85) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:63) at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:47) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66) at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:47) at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:151) at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:88) at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:85) at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:102) at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:108) at com.servepath.changerequest.ChangeRequestTest.testError(ChangeRequestTest.java:71) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580) at org.testng.internal.MethodHelper$1.runTestMethod(MethodHelper.java:698) at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:140) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.testng.internal.MethodHelper.invokeHookable(MethodHelper.java:706) at org.testng.internal.Invoker.invokeMethod(Invoker.java:468) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110) at org.testng.TestRunner.runWorkers(TestRunner.java:712) at org.testng.TestRunner.privateRun(TestRunner.java:582) at org.testng.TestRunner.run(TestRunner.java:477) at org.testng.SuiteRunner.runTest(SuiteRunner.java:324) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292) at org.testng.SuiteRunner.run(SuiteRunner.java:198) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:821) at org.testng.TestNG.runSuitesLocally(TestNG.java:788) at org.testng.TestNG.run(TestNG.java:708) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:74) at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92) at org.apache.maven.surefire.Surefire.run(Surefire.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997) [myproject] DEBUG [main] DefaultExceptionPolicyStrategy.getExceptionPolicy(46) | Finding best suited exception policy for thrown exception java.lang.I llegalArgumentException [myproject] DEBUG [main] DefaultExceptionPolicyStrategy.getExceptionPolicy(87) | No candidate found to be used as exception policy [myproject] DEBUG [main] RedeliveryPolicy.sleep(104) | Sleeping for: 1000 millis until attempting redelivery* ------=_Part_51148_15069580.1222803584202--