On Wed, Dec 16, 2009 at 12:20 AM, ychawla <[email protected]> wrote:
>
> Hello All,
> I am trying to use Camel to write a simple monitoring application.  I want
> to check to try to connect to multiple URLs and then if any of them fail,
> send an email altering an admin.
>
> My strategy was to use timer to run the application at a given interval and
> then create a dynamic Recipient List of the URLs and catch any exceptions.
> Here is an example (using a static recipient list for simplicity):
>
> <camel:camelContext xmlns="http://camel.apache.org/schema/spring";
> id="camel">
>  <route>
>        <from uri="timer://foo?fixedRate=true&period=60000"/>
>        <doTry>
>          <setHeader headerName="CamelHttpMethod">
>           <constant>GET</constant>
>          </setHeader>
>
>         <recipientList delimiter=",">
>          <constant>https://fail.test.com,
> https://succeed.test.com,https://fail2.test.com</constant>
>         </recipientList>
>
>         <doCatch>
>          <exception>java.lang.Exception</exception>
>          <camel:setBody><simple>URL that is failing:
> ${exception.message}</simple></camel:setBody>
>          <to uri="file:/home/yogesh/Desktop/pickup/Error"/>
>         </doCatch>
>        </doTry>
>  </route>
> </camel:camelContext>
>
> What I find is that both URL fail1 and fail2 throw exceptions, however, the
> catch block will only display the second exception in the exception.message
> expression.  Is there a way to save a history of all the exceptions?  Is
> there a way to enter the catch block multiple times?  Is there a different
> way to setup my route that is better than recipient list?  I have a spring
> config file that already has the list of URLs that need to be called so I
> just want to read that file, do an HTTP GET and if there is an error route
> to an error URI.
>
> Any help would be appreciated.
>

In Camel 2.2 the recipient list have been improved to allow you to
configure an AggregationStrategy which is what you need.
With this strategy you can merge those exceptions been thrown.

In 2.1 or older this was not possible to configure with recipient
list. For that you had to write your own processor logic for that.
Which frankly is also easy as you can just use a Processor / Bean and
invoke the endpoints yourself and catch the exceptions one by one.

Using ProducerTemplate makes it easy to invoke any endpoint.




> Thanks,
> Yogesh
>
> --
> View this message in context: 
> http://old.nabble.com/Recipient-List---Multiple-Exceptions-tp26803513p26803513.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
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

Reply via email to