camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Exception details
Date Wed, 29 Sep 2010 09:18:55 GMT
And when using Spring you need to ensure the namespace is on all the
tags outside camelContext.

The one below dont have namespace, which it need to have
>>        <errorHandler id="errorHandler" type="DeadLetterChannel"
>>                deadLetterUri="direct:errorHandlerRoute" />


On Wed, Sep 29, 2010 at 11:17 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
> Just use "direct:errorHandlerRoute" instead of ref:direct:errorHandlerRoute
>
> On Wed, Sep 29, 2010 at 10:49 AM,  <Steve.Hedges@barclayscapital.com> wrote:
>> Claus
>>
>> This is the relevant (more complete) extract of the spring config:
>>
>>
>>        <errorHandler id="loggingErrorHandler" type="LoggingErrorHandler"
>>                level="INFO" xmlns="http://camel.apache.org/schema/spring"
/>
>>
>>        <errorHandler id="errorHandler" type="DeadLetterChannel"
>>                deadLetterUri="direct:errorHandlerRoute" />
>>
>>        <camelContext id="camel" xmlns:stp="http://www.barcap.com/gcd/stpengine/1-0">
>>
>>                <template id="camelTemplate" />
>>
>>                <endpoint id="JMS_IN" uri="jms:queue:${input.queue}" />
>>                <endpoint id="JMS_OUT" uri="jms:queue:${output.queue}"
/>
>>                <endpoint id="JMS_ERROR" uri="jms:queue:${error.queue}"
/>
>>
>>
>>                <route>
>>                        <from ref="direct:errorHandlerRoute"/>
>>                        <log message="RAISED EXCEPTION: ${exception}"
loggingLevel="ERROR"/>
>>                        <to ref="JMS_ERROR"/>
>>                </route>
>>
>>                <route id="compression-workflow" errorHandlerRef="errorHandler">
>>                        <from ref="JMS_IN" />
>>
>> ...
>>
>> Execution gives the following error:
>>
>> INFO: Apache Camel 2.5-SNAPSHOT (CamelContext: camel) is shutdown in 0.016 seconds
>> Exception in thread "main" org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException:
Failed to create route route1: Route[[From[ref:direct:errorHandlerRoute]] -> [Log[RAISED
EX... because of No endpoint could be found for: ref:direct:errorHandlerRoute, please check
your camel registry with id direct:errorHandlerRoute
>>        at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1133)
>>        at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
>>        at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:236)
>>        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
>>        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:303)
>>        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:911)
>>        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:428)
>>        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
>>        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
>>        at com.barcap.gcdit.compressionworkflow.CompressionWorkflow.<init>(CompressionWorkflow.java:20)
>>        at com.barcap.gcdit.compressionworkflow.CompressionWorkflow.main(CompressionWorkflow.java:16)
>> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route
route1: Route[[From[ref:direct:errorHandlerRoute]] -> [Log[RAISED EX... because of No endpoint
could be found for: ref:direct:errorHandlerRoute, please check your camel registry with id
direct:errorHandlerRoute
>>        at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:179)
>>        at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:607)
>>
>>
>> My theory is that the errroHandler (which is defined outside the camelContext) cannot
refer to a route (which is defined inside the camelContext).  Given that you said this was
straightforward using the Java DSL, does this mean the Spring XML is weaker/deficient?  Or
have I hust made some obvois blatant error?  (Latter is by far the most likely.)
>>
>>
>> Thanks
>>
>> Steven Hedges
>> IT - Credit Booking Derivs
>>
>>
>> -----Original Message-----
>> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
>> Sent: 28 September 2010 18:30
>> To: users@camel.apache.org
>> Subject: Re: Exception details
>>
>> You need to set the errorHandlerRef attribute on either the <camelContext>
or the <route> in which the error handler should apply.
>>
>>
>>
>> On Tue, Sep 28, 2010 at 6:14 PM,  <Steve.Hedges@barclayscapital.com> wrote:
>>> Claus
>>>
>>> I am having difficulty with this as I am using the Spring XML config approach.
 The errorHandler is defined outside of the camelContext while the routes are defied inside
the camel context.  At the point at which the errorHandler is instantiated it cannot see
the error route.
>>>
>>> So I have:
>>>
>>>        <errorHandler id="errorHandler" type="DeadLetterChannel"
>>>                deadLetterUri="direct:errorHandlerRoute" />
>>>
>>> And
>>>
>>>        <camelContext id="camel"
>>> xmlns:stp="http://www.barcap.com/gcd/stpengine/1-0">
>>> ...
>>>
>>>                <route id="errorHandlerRoute">
>>>
>>>                        <log message="RAISED EXCEPTION: ${exception}"
>>> loggingLevel="ERROR"/>
>>>                        <to ref="JMS_ERROR"/>
>>>                </route>
>>>
>>> ...
>>> />
>>>
>>> I'm guessing that this would not be a problem using the Java DSL.  But I really
don't want to use that approach.  (From a commercial point of view, ease of writing code
in no way outweighs the advantages of having XML configs that can be read by support staff
at 2am).
>>>
>>> Your continuing help is much appreciated
>>>
>>>
>>> Steven Hedges
>>> IT - Credit Booking Derivs
>>>
>>>
>>> -----Original Message-----
>>> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
>>> Sent: 28 September 2010 16:35
>>> To: users@camel.apache.org
>>> Subject: Re: Exception details
>>>
>>> On Tue, Sep 28, 2010 at 5:27 PM,  <Steve.Hedges@barclayscapital.com> wrote:
>>>> You realise I am going to have to get my 50 c of help now :-)
>>>>
>>>> Is it possible to use a route as an error handler?  I would like to be able
to log an exception, raise an SMS and push the message onto a queue for later reprocessing.
 We are trying to keep all of our config in the Spring XML.  (Config file releases are much
simpler admin-wise than code releases).
>>>>
>>>
>>> Yeah use the DeadLetterChannel and set the endpoint to a
>>> direct:myRoute
>>>
>>> And then define a route with from("direct:myRoute") and its just like any other
route.
>>>
>>>
>>>>
>>>> Steven Hedges
>>>> IT - Credit Booking Derivs
>>>>
>>>> -----Original Message-----
>>>> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
>>>> Sent: 28 September 2010 16:13
>>>> To: users@camel.apache.org
>>>> Subject: Re: Exception details
>>>>
>>>> On Tue, Sep 28, 2010 at 3:46 PM,  <Steve.Hedges@barclayscapital.com>
wrote:
>>>>> I've bought the book!
>>>>>
>>>>
>>>> Ah great. Then Jonathan and I earned 50 cent today.
>>>>
>>>> I hope the book will help and inspire you with your current endeavor with
Camel. Good luck.
>>>>
>>>>>
>>>>>
>>>>> Steven Hedges
>>>>> IT - Credit Booking Derivs
>>>>>
>>>>> 10 The South Colonnade
>>>>> Canary Wharf,
>>>>> London E14 4PU,
>>>>> United Kingdom
>>>>>
>>>>> 02031344655
>>>>> x44655
>>>>>
>>>>> -----Original Message-----
>>>>> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
>>>>> Sent: 28 September 2010 14:33
>>>>> To: users@camel.apache.org
>>>>> Subject: Re: Exception details
>>>>>
>>>>> On Tue, Sep 28, 2010 at 3:26 PM,  <Steve.Hedges@barclayscapital.com>
wrote:
>>>>>> I'll get the book...
>>>>>>
>>>>>> From the info on that page, is it correct to assume that it is impossible
to get at the exception info from the Spring XML config?  All I want to do is to log the
actual exception to a file.
>>>>>>
>>>>>
>>>>> The simple language can access the caused exception using $exception
>>>>> See simple http://camel.apache.org/simple
>>>>>
>>>>> Something like this:
>>>>>
>>>>> onException(Exception.class).handled(true).transform(simple("Damn
>>>>> the problem is $exception.message and
>>>>> stacktrace\n$exception")).to("file:errors");
>>>>>
>>>>> But reading the entire chapter 5 about error handling will help you understand
some of the many features it provides.
>>>>> The wiki pages is a bit of a mess here and there for error handling as
its a hard topic to document well.
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>>> Steven Hedges
>>>>>> IT - Credit Booking Derivs
>>>>>>
>>>>>>
>>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
>>>>>> Sent: 28 September 2010 14:09
>>>>>> To: users@camel.apache.org
>>>>>> Subject: Re: Exception details
>>>>>>
>>>>>> On Tue, Sep 28, 2010 at 2:49 PM,  <Steve.Hedges@barclayscapital.com>
wrote:
>>>>>>> Hi
>>>>>>>
>>>>>>> This is probably very straightforward, but I've scoured the docs
and can't find an answer.
>>>>>>>
>>>>>>> Is it possible to get details of the actual exception that
>>>>>>> occurred in an error handler?  So far, I can see how to access
the
>>>>>>> message that caused an error (using the $body variable) but not
>>>>>>> the exception itself
>>>>>>>
>>>>>>
>>>>>> Yeah if you got the Camel in Action book, see section 5.4.4
>>>>>>
>>>>>> And you can find also some details about it here
>>>>>> http://camel.apache.org/exception-clause.html
>>>>>>
>>>>>> see section _Using a processor as failure handler_
>>>>>>
>>>>>>> Thanks in advance
>>>>>>>
>>>>>>>
>>>>>>> Steven Hedges
>>>>>>> IT - Credit Booking Derivs
>>>>>>>
>>>>>>> 10 The South Colonnade
>>>>>>> Canary Wharf,
>>>>>>> London E14 4PU,
>>>>>>> United Kingdom
>>>>>>>
>>>>>>> 02031344655
>>>>>>> x44655
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>>
>>>>>>> This e-mail may contain information that is confidential, privileged
or otherwise protected from disclosure. If you are not an intended recipient of this e-mail,
do not duplicate or redistribute it by any means. Please delete it and any attachments and
notify the sender that you have received it in error. Unless specifically indicated, this
e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment
products or other financial product or service, an official confirmation of any transaction,
or an official statement of Barclays. Any views or opinions presented are solely those of
the author and do not necessarily represent those of Barclays. This e-mail is subject to terms
available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays
you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays
Bank PLC, a company registered in England (number 1026167) with its registered office at 1
Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members
of the Barclays Group.
>>>>>>> _______________________________________________
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Claus Ibsen
>>>>>> Apache Camel Committer
>>>>>>
>>>>>> Author of Camel in Action: http://www.manning.com/ibsen/ Open
>>>>>> Source
>>>>>> Integration: http://fusesource.com
>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>> Twitter: http://twitter.com/davsclaus
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Claus Ibsen
>>>>> Apache Camel Committer
>>>>>
>>>>> Author of Camel in Action: http://www.manning.com/ibsen/ Open Source
>>>>> Integration: http://fusesource.com
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>> Twitter: http://twitter.com/davsclaus
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> Apache Camel Committer
>>>>
>>>> Author of Camel in Action: http://www.manning.com/ibsen/ Open Source
>>>> Integration: http://fusesource.com
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Twitter: http://twitter.com/davsclaus
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Author of Camel in Action: http://www.manning.com/ibsen/ Open Source
>>> Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration:
http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message