You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "suyash.singh" <su...@gmail.com> on 2013/06/03 09:47:42 UTC

Problem with runTimeException handling.

Hi,

We are developing an app using Apache Camel and using timers to control
sessions. When a timer expires, we throw a runtimeException to send a
message to the customer. The CAMEL route in the meantime does not continue
as a result and breaks out of the pipeline.

In certain cases, we would like the CAMEL route to continue inspite of a
RunTimeException being raised. Any ideas on how to do this?



--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-runTimeException-handling-tp5733659.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with runTimeException handling.

Posted by Christian Müller <ch...@gmail.com>.
Yes. Have a look at [1] and [2].

If you have a route like:
from("direct:start")
  .enrich("jetty:xxx", aggregationStrategy)
  .to("direct:yyy");

you can decide which payload is routed in your main route in your
aggregationStrategy. It can be the payload which arrived in the enricher,
the payload received from the jetty call or something different...

[1] http://camel.apache.org/content-enricher.html
[2]
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/aggregate/AggregationStrategy.html

Best,

Christian Müller
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Mon, Jun 10, 2013 at 12:24 PM, suyash.singh <su...@gmail.com>wrote:

> To add to my previous post - basically I want to send a message out from
> Jetty mid-route and then continue the route as is. Is this possible?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Problem-with-runTimeException-handling-tp5733659p5734059.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Problem with runTimeException handling.

Posted by "suyash.singh" <su...@gmail.com>.
To add to my previous post - basically I want to send a message out from
Jetty mid-route and then continue the route as is. Is this possible?



--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-runTimeException-handling-tp5733659p5734059.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with runTimeException handling.

Posted by "suyash.singh" <su...@gmail.com>.
Hi Claus,

So where is what I have accomplished:

1) I am in Bean 1.
2) I get the timer-expiry and handle it with OnException and I set it as
Continued because if I set it to handled, the pipe breaks and nothing goes
out to caller.
3) I set a reply message in exchange
4) NOW I need to wait for Bean 2 to finish before this travels back to jetty
and out to the caller.

Can I break route at Step 3 and sent something back instantly - without
going to Bean 2.



--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-runTimeException-handling-tp5733659p5734008.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with runTimeException handling.

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

You can use onException to catch and handle the runtime exception, and
there you can do set some "reply message" you want to caller to see.
And remember to set a status code of 500+ if you want to tell the
caller that there was some internal server error etc.

And no you cannot route to bean2 after sending back the reply message.

If you want to do so, you would need to use wire tap or the likes to
spin off a 2nd message.

On Thu, Jun 6, 2013 at 1:04 PM, suyash.singh <su...@gmail.com> wrote:
> Hi Claus,
>
> Thanks for the quick reply but I think I explained my problem incorrectly.
> So here I try again:
>
> 1) My route flows like HTTP Req -> Jetty -> Bean1 -> Bean 2 -> Route END.
> After this a HTTP reply goes back to sender.
> 2) Now say for e.g. during bean 1 I encounter a timer expiry. I handle this
> using runtime exception in which I want to do a HTTP reply back to sender to
> tell him of this expiry.
>
> Question is, can I get the Jetty context on a ad-hoc basis. Also can the
> route continue to Bean 2 after I send this reply.
>
>
> Hope I have done a better job this time
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-runTimeException-handling-tp5733659p5733939.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Problem with runTimeException handling.

Posted by "suyash.singh" <su...@gmail.com>.
Hi Claus,

Thanks for the quick reply but I think I explained my problem incorrectly.
So here I try again:

1) My route flows like HTTP Req -> Jetty -> Bean1 -> Bean 2 -> Route END.
After this a HTTP reply goes back to sender.
2) Now say for e.g. during bean 1 I encounter a timer expiry. I handle this
using runtime exception in which I want to do a HTTP reply back to sender to
tell him of this expiry.

Question is, can I get the Jetty context on a ad-hoc basis. Also can the
route continue to Bean 2 after I send this reply.


Hope I have done a better job this time



--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-runTimeException-handling-tp5733659p5733939.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with runTimeException handling.

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

If you have a copy of Camel in Action, see chapter 5, section 5.4.5

You can tell Camel to continue with the onException.

You can find a bit of information on the Camel web site also about this.



On Mon, Jun 3, 2013 at 9:47 AM, suyash.singh <su...@gmail.com> wrote:
> Hi,
>
> We are developing an app using Apache Camel and using timers to control
> sessions. When a timer expires, we throw a runtimeException to send a
> message to the customer. The CAMEL route in the meantime does not continue
> as a result and breaks out of the pipeline.
>
> In certain cases, we would like the CAMEL route to continue inspite of a
> RunTimeException being raised. Any ideas on how to do this?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-runTimeException-handling-tp5733659.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen