You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by moj0002 <mo...@hotmail.com> on 2014/03/17 03:48:26 UTC

retrieving iru in onException

I am trying to write a simple "ping" application. I ping urls in a multicast
and if there is a connection exception I catch it in a onException which
calls a aggregation that builds an email

If myFirstURLToPing is down I can't figure out out how to pass the URL via
the Exception to the email body.

I can't find something like ${to.uri} in the Message or Exchange. This seems
that it should be easy to get from the exception but I can't find any
references to the uri variable.

<route >
            <from uri="timer://foo?fixedRate=true&amp;period=3600000"
id="pingTine"/>
            <multicast>
                <to http://myFirstURLToPing:1234" />
                <to http://mySecondURLToPing:1234" />
                <to http://myThirdURLToPing:1234" />

            </multicast>
 </route>


<onException useOriginalMessage="true">
            <exception>java.net.ConnectException</exception>
            <exception>java.net.UnknownHostException</exception>
            <handled>
                <constant>true</constant>
            </handled>
            <transform>
                <simple>DOWN  >>>  <HERE  SHOLD the URI BE
DISPLAYED></simple>
            </transform>
           <to uri="direct:buildEmaiBody"/> 
</onException>


<route>
<from uri="direct:buildEmaiBody"/>
<aggregate strategyRef="mailBodyAppender" strategyMethodName="append"
completionTimeout="20000">
<correlationExpression>
   <constant>true</constant>
 </correlationExpression>
 <to smpt://.../>
  </aggregate>
</route>

I would want my email to show

DOWN  >>> http://myFirstURLToPing:1234
DOWN  >>> http://myThirdURLToPing:1234

I have figured out a way by creating a route for each URL to ping, naming
the route the same as the URL to ping and then use ${routeId} but that seems
very clumpsy



--
View this message in context: http://camel.465427.n5.nabble.com/retrieving-iru-in-onException-tp5748904.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: retrieving iru in onException

Posted by moj0002 <mo...@hotmail.com>.
Took me a bit to figure out how to retrieve the FAILURE_ENDPOINT from Simple,
I didn't understand the that default value "CamelFailureEndpoint" for
FAILURE_ENDPOINT also is the key used in the properties map on the Exchange. 
Probably very obvious if you know, I guess I jumped a few chapters ahead
without getting the basics down....   Reading the documentation for
DeadLetterChannel it is spelled out, I just didn't connect the dots.  

This now works with multicast
<simple>DOWN >> ${property.CamelFailureEndpoint}</simple>

Thanks for your help.




--
View this message in context: http://camel.465427.n5.nabble.com/retrieving-uri-in-onException-tp5748904p5749289.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: retrieving iru in onException

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

See
https://camel.apache.org/dead-letter-channel.html

about which endpoint failed.


On Mon, Mar 17, 2014 at 3:48 AM, moj0002 <mo...@hotmail.com> wrote:
> I am trying to write a simple "ping" application. I ping urls in a multicast
> and if there is a connection exception I catch it in a onException which
> calls a aggregation that builds an email
>
> If myFirstURLToPing is down I can't figure out out how to pass the URL via
> the Exception to the email body.
>
> I can't find something like ${to.uri} in the Message or Exchange. This seems
> that it should be easy to get from the exception but I can't find any
> references to the uri variable.
>
> <route >
>             <from uri="timer://foo?fixedRate=true&period=3600000"
> id="pingTine"/>
>             <multicast>
>                 <to http://myFirstURLToPing:1234" />
>                 <to http://mySecondURLToPing:1234" />
>                 <to http://myThirdURLToPing:1234" />
>
>             </multicast>
>  </route>
>
>
> <onException useOriginalMessage="true">
>             <exception>java.net.ConnectException</exception>
>             <exception>java.net.UnknownHostException</exception>
>             <handled>
>                 <constant>true</constant>
>             </handled>
>             <transform>
>                 <simple>DOWN  >>>  <HERE  SHOLD the URI BE
> DISPLAYED></simple>
>             </transform>
>            <to uri="direct:buildEmaiBody"/>
> </onException>
>
>
> <route>
> <from uri="direct:buildEmaiBody"/>
> <aggregate strategyRef="mailBodyAppender" strategyMethodName="append"
> completionTimeout="20000">
> <correlationExpression>
>    <constant>true</constant>
>  </correlationExpression>
>  <to smpt://.../>
>   </aggregate>
> </route>
>
> I would want my email to show
>
> DOWN  >>> http://myFirstURLToPing:1234
> DOWN  >>> http://myThirdURLToPing:1234
>
> I have figured out a way by creating a route for each URL to ping, naming
> the route the same as the URL to ping and then use ${routeId} but that seems
> very clumpsy
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/retrieving-iru-in-onException-tp5748904.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io