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: Throwing exceptions from Enrichers
Date Fri, 26 Nov 2010 08:54:24 GMT
On Fri, Nov 26, 2010 at 9:48 AM, Glen Robson <glen.robson@llgc.org.uk> wrote:
> Hi,
>
> I was wondering what the best way to throw an exception from an aggregator
> is so I can catch it in the camel route. Currently I have the following
> route:
>
> <route>
>            <from uri="jms:ethos_marc_loaded" />
>            <bean ref="marc2marcxml" />
>            <setHeader headerName="CamelHttpUri">
>
>  <simple>http://localhost:8888/ethos/upload/${header.llgc_ethos_oai_harvest_location}/${header.llgc_ethos_transaction_id}/mets.xml</simple>
>            </setHeader>
>            <enrich uri="http://localhost:8888" strategyRef="AddBibIdsToMETS"
> />
>            <to uri="jms:ethos_ingest" />
> </route>
>
> <bean id="AddBibIdsToMETS"
> class="uk.org.llgc.projects.ethos.AddBibIdsToMETS" />
>
> AddBibIdsToMETS is a custom aggregation strategy implementing the
> org.apache.camel.processor.aggregate.AggregationStrategy interface and it
> implements the following method:
>
> Exchange aggregate(Exchange oldExchange, Exchange newExchange)
> which means I can't just throw the exception from the method.
>
> Whats the best way to get round this?
>
> Thanks for your help
>
> Glen

You can throw an runtime exception or set an exception on the exchange
you return using the setException method.




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

Mime
View raw message