You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by James Morgan <ja...@gmail.com> on 2011/01/14 13:59:17 UTC

Error when testing route config when using both onException and errorHandler in test which extend CamelSpringTestSupport

I have a working routing config, reasonably simple, just consumes from a
queue and does a little processing, it also has a a dead letter channel
defined.


I wanted to add an onException route for a specific exception which is
thrown from within a processor.

Exception extends RuntimeException (not sure if this make a difference)

When I add the below to catch this exception and do stuff with it, my tests
now throw some weird exception.

Exception I get is:

*Caused by: org.apache.camel.CamelExchangeException: No consumers available
on endpoint: Endpoint[direct://my-test-endpoint]*
*
*
As soon as I remove the onException route it passes.

I've been playing this for afew hours, cant find anything that's wrong. Even
when i print out the routes defined from in my test I see them all there?

Do you have any idea what's wrong?


onException(CustomException.class)
.handled(true)
 .process(new Processor() {
@Override
public void process(final Exchange exchange) throws Exception {
 // do stuff
}
})
 .to(deadLetterUri).end();

Re: Error when testing route config when using both onException and errorHandler in test which extend CamelSpringTestSupport

Posted by Claus Ibsen <cl...@gmail.com>.
I cannot reproduce this in Camel 2.6

I created this unit test which is similar to yours
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/OnExceptionBeforeErrorHandlerIssueTest.java



On Fri, Jan 14, 2011 at 4:27 PM, James Morgan <ja...@gmail.com> wrote:
> Thanks for your help in advance.
>
> Route config as follows:
>
> public void configure() throws Exception {
>
>
>
>                                //@formatter:off
>
>                                final String deadLetterUri =
> String.format("%s:%s", ROUTING_SCHEME, GECKO_FAILURES_QUEUE);
>
>
>
>                                onException(FailureException.class)
>
>                                                .handled(true)
>
>                                                .process(new Processor() {
>
>                                                                @Override
>
>                                                                public void
> process(final Exchange exchange) throws Exception {
>
>
> final FailureException exception = exchange.getProperty(EXCEPTION_CAUGHT,
> FailureException.class);
>
>
> final Message request = exchange.getIn();
>
>
> log.error("Failure when sending, request: " + request, exception);
>
>                                                                }
>
>                                                })
>
>                                .to(deadLetterUri).end();
>
>
>
>
> errorHandler(deadLetterChannel(deadLetterUri)
>
>                                                .maximumRedeliveries(0)
>
>
> .retriesExhaustedLogLevel(LoggingLevel.ERROR)
>
>
> .retryAttemptedLogLevel(LoggingLevel.WARN)
>
>
> .log("com.blah.blah.Failure")
>
>
> .loggingLevel(LoggingLevel.ERROR)
>
>                                                .logStackTrace(true)
>
>                                                .useOriginalMessage()
>
>                                );
>
>
>
>                                fromF(PRINT_REQUEST_QUEUE, ROUTING_SCHEME)
>
>                                                .noAutoStartup()
>
>                                                .id(ROUTE_ID)
>
>                                                .unmarshal()
>
>                                                .json(JsonLibrary.Jackson)
>
>
>
>                                                .setHeader("ClientId",
> constant(this.clientId))
>
>                                                .setHeader("jobRequestType",
> constant(getMode(currentMode).getRequestType()))
>
>                                                .setHeader("documentType",
> constant(this.documentType))
>
>                                                .setHeader("documentVersion",
> constant(this.documentVersion))
>
>
>
>
> .to("freemarker:translator.ftl?contentCache=false")
>
>
> .to("log:com.blah.blah.Transformer?level=DEBUG")
>
>
>
>                                                .to("validator:schema.xsd")
>
>
> .to("log:com.blah.blah.Validator?level=DEBUG")
>
>
>
>
> .to("freemarker:soap-translator.ftl?contentCache=false")
>
>
> .to("log:com.blah.blah.SoapEnhancement?level=DEBUG")
>
>
>
>                                                // Send request
>
>                                                .to("someProcessor");
>
>                                //@formatter:on
>
>                }
>
> Notice the route is stopped by default, I then have another "timer" router
> with processor attached to then enable/disable the route dependant on a
> service call.
>
>
> Thanks James.
>
>
>
> On 14 January 2011 15:11, Claus Ibsen <cl...@gmail.com> wrote:
>
>> Can you post your full route.
>>
>> And make sure you use .end() to denote the end of the onException if
>> its route scoped.
>>
>>
>> On Fri, Jan 14, 2011 at 2:49 PM, James Morgan <ja...@gmail.com>
>> wrote:
>> > Sorry camel version 2.5.0
>> >  On 14 Jan 2011 13:22, "Claus Ibsen" <cl...@gmail.com> wrote:
>> >> Hi
>> >>
>> >> Please always detail the Camel version used. It matter a lot for
>> >> people to help you.
>> >>
>> >> And always try using the latest released version to see if its fixed
>> > there.
>> >> And if possible the SNAPSHOT version as well.
>> >> http://camel.apache.org/download
>> >>
>> >> Each Camel release has a lot of improvements and bug fixes.
>> >>
>> >> And post the full route, stack trace and what not if its still an issue.
>> >>
>> >>
>> >>
>> >> On Fri, Jan 14, 2011 at 1:59 PM, James Morgan <james.morgan.e@gmail.com
>> >
>> > wrote:
>> >>> I have a working routing config, reasonably simple, just consumes from
>> a
>> >>> queue and does a little processing, it also has a a dead letter channel
>> >>> defined.
>> >>>
>> >>>
>> >>> I wanted to add an onException route for a specific exception which is
>> >>> thrown from within a processor.
>> >>>
>> >>> Exception extends RuntimeException (not sure if this make a difference)
>> >>>
>> >>> When I add the below to catch this exception and do stuff with it, my
>> > tests
>> >>> now throw some weird exception.
>> >>>
>> >>> Exception I get is:
>> >>>
>> >>> *Caused by: org.apache.camel.CamelExchangeException: No consumers
>> > available
>> >>> on endpoint: Endpoint[direct://my-test-endpoint]*
>> >>> *
>> >>> *
>> >>> As soon as I remove the onException route it passes.
>> >>>
>> >>> I've been playing this for afew hours, cant find anything that's wrong.
>> > Even
>> >>> when i print out the routes defined from in my test I see them all
>> there?
>> >>>
>> >>> Do you have any idea what's wrong?
>> >>>
>> >>>
>> >>> onException(CustomException.class)
>> >>> .handled(true)
>> >>>  .process(new Processor() {
>> >>> @Override
>> >>> public void process(final Exchange exchange) throws Exception {
>> >>>  // do stuff
>> >>> }
>> >>> })
>> >>>  .to(deadLetterUri).end();
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Claus Ibsen
>> >> -----------------
>> >> FuseSource
>> >> Email: cibsen@fusesource.com
>> >> Web: http://fusesource.com
>> >> Twitter: davsclaus
>> >> Blog: http://davsclaus.blogspot.com/
>> >> Author of Camel in Action: http://www.manning.com/ibsen/
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Error when testing route config when using both onException and errorHandler in test which extend CamelSpringTestSupport

Posted by James Morgan <ja...@gmail.com>.
Thanks for your help in advance.

Route config as follows:

public void configure() throws Exception {



                                //@formatter:off

                                final String deadLetterUri =
String.format("%s:%s", ROUTING_SCHEME, GECKO_FAILURES_QUEUE);



                                onException(FailureException.class)

                                                .handled(true)

                                                .process(new Processor() {

                                                                @Override

                                                                public void
process(final Exchange exchange) throws Exception {


final FailureException exception = exchange.getProperty(EXCEPTION_CAUGHT,
FailureException.class);


final Message request = exchange.getIn();


log.error("Failure when sending, request: " + request, exception);

                                                                }

                                                })

                                .to(deadLetterUri).end();




errorHandler(deadLetterChannel(deadLetterUri)

                                                .maximumRedeliveries(0)


.retriesExhaustedLogLevel(LoggingLevel.ERROR)


.retryAttemptedLogLevel(LoggingLevel.WARN)


.log("com.blah.blah.Failure")


.loggingLevel(LoggingLevel.ERROR)

                                                .logStackTrace(true)

                                                .useOriginalMessage()

                                );



                                fromF(PRINT_REQUEST_QUEUE, ROUTING_SCHEME)

                                                .noAutoStartup()

                                                .id(ROUTE_ID)

                                                .unmarshal()

                                                .json(JsonLibrary.Jackson)



                                                .setHeader("ClientId",
constant(this.clientId))

                                                .setHeader("jobRequestType",
constant(getMode(currentMode).getRequestType()))

                                                .setHeader("documentType",
constant(this.documentType))

                                                .setHeader("documentVersion",
constant(this.documentVersion))




.to("freemarker:translator.ftl?contentCache=false")


.to("log:com.blah.blah.Transformer?level=DEBUG")



                                                .to("validator:schema.xsd")


.to("log:com.blah.blah.Validator?level=DEBUG")




.to("freemarker:soap-translator.ftl?contentCache=false")


.to("log:com.blah.blah.SoapEnhancement?level=DEBUG")



                                                // Send request

                                                .to("someProcessor");

                                //@formatter:on

                }

Notice the route is stopped by default, I then have another "timer" router
with processor attached to then enable/disable the route dependant on a
service call.


Thanks James.



On 14 January 2011 15:11, Claus Ibsen <cl...@gmail.com> wrote:

> Can you post your full route.
>
> And make sure you use .end() to denote the end of the onException if
> its route scoped.
>
>
> On Fri, Jan 14, 2011 at 2:49 PM, James Morgan <ja...@gmail.com>
> wrote:
> > Sorry camel version 2.5.0
> >  On 14 Jan 2011 13:22, "Claus Ibsen" <cl...@gmail.com> wrote:
> >> Hi
> >>
> >> Please always detail the Camel version used. It matter a lot for
> >> people to help you.
> >>
> >> And always try using the latest released version to see if its fixed
> > there.
> >> And if possible the SNAPSHOT version as well.
> >> http://camel.apache.org/download
> >>
> >> Each Camel release has a lot of improvements and bug fixes.
> >>
> >> And post the full route, stack trace and what not if its still an issue.
> >>
> >>
> >>
> >> On Fri, Jan 14, 2011 at 1:59 PM, James Morgan <james.morgan.e@gmail.com
> >
> > wrote:
> >>> I have a working routing config, reasonably simple, just consumes from
> a
> >>> queue and does a little processing, it also has a a dead letter channel
> >>> defined.
> >>>
> >>>
> >>> I wanted to add an onException route for a specific exception which is
> >>> thrown from within a processor.
> >>>
> >>> Exception extends RuntimeException (not sure if this make a difference)
> >>>
> >>> When I add the below to catch this exception and do stuff with it, my
> > tests
> >>> now throw some weird exception.
> >>>
> >>> Exception I get is:
> >>>
> >>> *Caused by: org.apache.camel.CamelExchangeException: No consumers
> > available
> >>> on endpoint: Endpoint[direct://my-test-endpoint]*
> >>> *
> >>> *
> >>> As soon as I remove the onException route it passes.
> >>>
> >>> I've been playing this for afew hours, cant find anything that's wrong.
> > Even
> >>> when i print out the routes defined from in my test I see them all
> there?
> >>>
> >>> Do you have any idea what's wrong?
> >>>
> >>>
> >>> onException(CustomException.class)
> >>> .handled(true)
> >>>  .process(new Processor() {
> >>> @Override
> >>> public void process(final Exchange exchange) throws Exception {
> >>>  // do stuff
> >>> }
> >>> })
> >>>  .to(deadLetterUri).end();
> >>>
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> -----------------
> >> FuseSource
> >> Email: cibsen@fusesource.com
> >> Web: http://fusesource.com
> >> Twitter: davsclaus
> >> Blog: http://davsclaus.blogspot.com/
> >> Author of Camel in Action: http://www.manning.com/ibsen/
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Re: Error when testing route config when using both onException and errorHandler in test which extend CamelSpringTestSupport

Posted by Claus Ibsen <cl...@gmail.com>.
Can you post your full route.

And make sure you use .end() to denote the end of the onException if
its route scoped.


On Fri, Jan 14, 2011 at 2:49 PM, James Morgan <ja...@gmail.com> wrote:
> Sorry camel version 2.5.0
>  On 14 Jan 2011 13:22, "Claus Ibsen" <cl...@gmail.com> wrote:
>> Hi
>>
>> Please always detail the Camel version used. It matter a lot for
>> people to help you.
>>
>> And always try using the latest released version to see if its fixed
> there.
>> And if possible the SNAPSHOT version as well.
>> http://camel.apache.org/download
>>
>> Each Camel release has a lot of improvements and bug fixes.
>>
>> And post the full route, stack trace and what not if its still an issue.
>>
>>
>>
>> On Fri, Jan 14, 2011 at 1:59 PM, James Morgan <ja...@gmail.com>
> wrote:
>>> I have a working routing config, reasonably simple, just consumes from a
>>> queue and does a little processing, it also has a a dead letter channel
>>> defined.
>>>
>>>
>>> I wanted to add an onException route for a specific exception which is
>>> thrown from within a processor.
>>>
>>> Exception extends RuntimeException (not sure if this make a difference)
>>>
>>> When I add the below to catch this exception and do stuff with it, my
> tests
>>> now throw some weird exception.
>>>
>>> Exception I get is:
>>>
>>> *Caused by: org.apache.camel.CamelExchangeException: No consumers
> available
>>> on endpoint: Endpoint[direct://my-test-endpoint]*
>>> *
>>> *
>>> As soon as I remove the onException route it passes.
>>>
>>> I've been playing this for afew hours, cant find anything that's wrong.
> Even
>>> when i print out the routes defined from in my test I see them all there?
>>>
>>> Do you have any idea what's wrong?
>>>
>>>
>>> onException(CustomException.class)
>>> .handled(true)
>>>  .process(new Processor() {
>>> @Override
>>> public void process(final Exchange exchange) throws Exception {
>>>  // do stuff
>>> }
>>> })
>>>  .to(deadLetterUri).end();
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Error when testing route config when using both onException and errorHandler in test which extend CamelSpringTestSupport

Posted by James Morgan <ja...@gmail.com>.
Sorry camel version 2.5.0
 On 14 Jan 2011 13:22, "Claus Ibsen" <cl...@gmail.com> wrote:
> Hi
>
> Please always detail the Camel version used. It matter a lot for
> people to help you.
>
> And always try using the latest released version to see if its fixed
there.
> And if possible the SNAPSHOT version as well.
> http://camel.apache.org/download
>
> Each Camel release has a lot of improvements and bug fixes.
>
> And post the full route, stack trace and what not if its still an issue.
>
>
>
> On Fri, Jan 14, 2011 at 1:59 PM, James Morgan <ja...@gmail.com>
wrote:
>> I have a working routing config, reasonably simple, just consumes from a
>> queue and does a little processing, it also has a a dead letter channel
>> defined.
>>
>>
>> I wanted to add an onException route for a specific exception which is
>> thrown from within a processor.
>>
>> Exception extends RuntimeException (not sure if this make a difference)
>>
>> When I add the below to catch this exception and do stuff with it, my
tests
>> now throw some weird exception.
>>
>> Exception I get is:
>>
>> *Caused by: org.apache.camel.CamelExchangeException: No consumers
available
>> on endpoint: Endpoint[direct://my-test-endpoint]*
>> *
>> *
>> As soon as I remove the onException route it passes.
>>
>> I've been playing this for afew hours, cant find anything that's wrong.
Even
>> when i print out the routes defined from in my test I see them all there?
>>
>> Do you have any idea what's wrong?
>>
>>
>> onException(CustomException.class)
>> .handled(true)
>>  .process(new Processor() {
>> @Override
>> public void process(final Exchange exchange) throws Exception {
>>  // do stuff
>> }
>> })
>>  .to(deadLetterUri).end();
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/

Re: Error when testing route config when using both onException and errorHandler in test which extend CamelSpringTestSupport

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Please always detail the Camel version used. It matter a lot for
people to help you.

And always try using the latest released version to see if its fixed there.
And if possible the SNAPSHOT version as well.
http://camel.apache.org/download

Each Camel release has a lot of improvements and bug fixes.

And post the full route, stack trace and what not if its still an issue.



On Fri, Jan 14, 2011 at 1:59 PM, James Morgan <ja...@gmail.com> wrote:
> I have a working routing config, reasonably simple, just consumes from a
> queue and does a little processing, it also has a a dead letter channel
> defined.
>
>
> I wanted to add an onException route for a specific exception which is
> thrown from within a processor.
>
> Exception extends RuntimeException (not sure if this make a difference)
>
> When I add the below to catch this exception and do stuff with it, my tests
> now throw some weird exception.
>
> Exception I get is:
>
> *Caused by: org.apache.camel.CamelExchangeException: No consumers available
> on endpoint: Endpoint[direct://my-test-endpoint]*
> *
> *
> As soon as I remove the onException route it passes.
>
> I've been playing this for afew hours, cant find anything that's wrong. Even
> when i print out the routes defined from in my test I see them all there?
>
> Do you have any idea what's wrong?
>
>
> onException(CustomException.class)
> .handled(true)
>  .process(new Processor() {
> @Override
> public void process(final Exchange exchange) throws Exception {
>  // do stuff
> }
> })
>  .to(deadLetterUri).end();
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/