You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Zhemzhitsky Sergey <Se...@troika.ru> on 2011/07/01 13:30:07 UTC

Is it possible to propagate an exception to the parent route?

Hi there,

I'm wondering whether it is possible to propagate an exception to the parent route?

My configuration is the following:

<route id="parent">
  <from uri="direct://parent"/>
  <to uri="direct://child"/>
  <onException>
    <exception>org.test.MyException</exception>
    <!-do something -->
  </onException>
</route>

<route id="child">
   <from uri=" direct://child"/>
   <throwException ref="myException"/>
</route>

Is it possible to handle an exception thrown in the child route in the parent route?

Best Regards,
Sergey Zhemzhitsky


_______________________________________________________

The information contained in this message may be privileged and conf idential and protected from disclosure. If you are not the original intended recipient, you are hereby notified that any review, retransmission, dissemination, or other use of, or taking of any action in reliance upon, this information is prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and delete it from your computer. Thank you for your cooperation. Troika Dialog, Russia. 
If you need assistance please contact our Contact Center  (+7495) 258 0500 or go to www.troika.ru/eng/Contacts/system.wbp  


Re: Is it possible to propagate an exception to the parent route?

Posted by Andrè <mo...@web.de>.
ok i did  it this way:

Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
Exception.class);

i throught the exception is always set in the exchange, that is not correct.
you have  access it through the properties


--
View this message in context: http://camel.465427.n5.nabble.com/Is-it-possible-to-propagate-an-exception-to-the-parent-route-tp4541827p4542786.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Is it possible to propagate an exception to the parent route?

Posted by Andrè <mo...@web.de>.
ok the  real problem is that the exeption is gone when i want to wrap it,
 is there an option to set the exception in the exchange in the doTry block
, or give it as an parameter to the processor ? 

--
View this message in context: http://camel.465427.n5.nabble.com/Is-it-possible-to-propagate-an-exception-to-the-parent-route-tp4541827p4542711.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Is it possible to propagate an exception to the parent route?

Posted by Andrè <mo...@web.de>.
ok i have to confess the nullpointer was my fault,but i still loose my 
parsing exception,

 has it something to do with the doTry? (it has, i believe i´m loosing it
there)

--
View this message in context: http://camel.465427.n5.nabble.com/Is-it-possible-to-propagate-an-exception-to-the-parent-route-tp4541827p4542623.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Is it possible to propagate an exception to the parent route?

Posted by Andrè <mo...@web.de>.
i´m trying that by wrapping an exception in a RuntimeCamelException and the
exception consumer is dewraping and throwing it again, 
but at the producer i´m getting a nullpointer, so somewhere i´m loosing the
exception, cause i should get the runtimecamelException ...

any ideas ? 
(thx, your answers already helped that much.. )
(Exception producer)
	<from
			
uri="activemq:topic:services.global.xacml.authzRequests?transferException=true"
/>
			<log message=" Xacml request consumed" />
			<doTry>
				<to uri="bean:pdp" />
				<doCatch>
					<exception>org.jboss.security.xacml.sunxacml.ParsingException
					</exception>
					<process ref="ExceptionWrapper"/>
				</doCatch>
			</doTry>
(Wrapper)
	public void process(Exchange exchange) throws Exception {
		
		Exception e = exchange.getException();
		RuntimeCamelException wrapper = new RuntimeCamelException(e.getCause());
		wrapper.setStackTrace(e.getStackTrace());
		exchange.setException(wrapper);

	}


(Exception consumer)
			<from uri="direct:AuthzService" />
			<to uri="bean:isAuthZBlocked?method=checkRequest" />
			<doTry>
				<to
				
uri="activemq:topic:services.global.xacml.authzRequests?transferException=true"
/>
				<doCatch>
					<exception>org.apache.camel.RuntimeCamelException</exception>
					<process ref="ExceptionDeWrapper" />
				</doCatch>
			</doTry>

(DeWrapper)
	public void process(Exchange exchange) throws Exception {
		throw exchange.getException(); 
}


--
View this message in context: http://camel.465427.n5.nabble.com/Is-it-possible-to-propagate-an-exception-to-the-parent-route-tp4541827p4542595.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Is it possible to propagate an exception to the parent route?

Posted by Charles Moulliard <cm...@gmail.com>.
Hi,

If you use an ActiveMQ/JMS endpoint (http://camel.apache.org/jms.html)
with exchange of type InOut = request/reply, then the exception can be
transfered back if you set the property

transferException=true

Regards,

Charles Moulliard

Apache Committer

Blog : http://cmoulliard.blogspot.com
Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard
Skype: cmoulliard



On Fri, Jul 1, 2011 at 1:43 PM, Andrè <mo...@web.de> wrote:
> this case ?
> what if the connection between the child and parent is
>
> an activemq topic ?
> an active queue ?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Is-it-possible-to-propagate-an-exception-to-the-parent-route-tp4541827p4541857.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Is it possible to propagate an exception to the parent route?

Posted by Andrè <mo...@web.de>.
this case ? 
what if the connection between the child and parent is 

an activemq topic ?
an active queue ? 

--
View this message in context: http://camel.465427.n5.nabble.com/Is-it-possible-to-propagate-an-exception-to-the-parent-route-tp4541827p4541857.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Is it possible to propagate an exception to the parent route?

Posted by Zhemzhitsky Sergey <Se...@troika.ru>.
Charles, thanks a lot.

Best Regards,
Sergey Zhemzhitsky
Information Technology Division
Troika Dialog, 4, Romanov lane, Moscow 125009, Russia
Phone. +7 495 2580500 ext. 1246


-----Original Message-----
From: Charles Moulliard [mailto:cmoulliard@gmail.com] 
Sent: Friday, July 01, 2011 3:38 PM
To: users@camel.apache.org
Subject: Re: Is it possible to propagate an exception to the parent route?

Yes. In this case, you must disable the errorHandler in the second route.

Here is a camel example showing that in action

https://svn.apache.org/repos/asf/camel/tags/camel-2.7.1/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionCallSubRouteNoErrorHandlerTest.java

Regards,

Charles Moulliard

Apache Committer

Blog : http://cmoulliard.blogspot.com
Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard
Skype: cmoulliard



2011/7/1 Zhemzhitsky Sergey <Se...@troika.ru>:
> Hi there,
>
> I'm wondering whether it is possible to propagate an exception to the parent route?
>
> My configuration is the following:
>
> <route id="parent">
>  <from uri="direct://parent"/>
>  <to uri="direct://child"/>
>  <onException>
>    <exception>org.test.MyException</exception>
>    <!-do something -->
>  </onException>
> </route>
>
> <route id="child">
>   <from uri=" direct://child"/>
>   <throwException ref="myException"/>
> </route>
>
> Is it possible to handle an exception thrown in the child route in the parent route?
>
> Best Regards,
> Sergey Zhemzhitsky
>
>
> _______________________________________________________
>
> The information contained in this message may be privileged and conf idential and protected from disclosure. If you are not the original intended recipient, you are hereby notified that any review, retransmission, dissemination, or other use of, or taking of any action in reliance upon, this information is prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and delete it from your computer. Thank you for your cooperation. Troika Dialog, Russia.
> If you need assistance please contact our Contact Center  (+7495) 258 0500 or go to www.troika.ru/eng/Contacts/system.wbp
>
>

_______________________________________________________

The information contained in this message may be privileged and conf idential and protected from disclosure. If you are not the original intended recipient, you are hereby notified that any review, retransmission, dissemination, or other use of, or taking of any action in reliance upon, this information is prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and delete it from your computer. Thank you for your cooperation. Troika Dialog, Russia. 
If you need assistance please contact our Contact Center  (+7495) 258 0500 or go to www.troika.ru/eng/Contacts/system.wbp  



Re: Is it possible to propagate an exception to the parent route?

Posted by Charles Moulliard <cm...@gmail.com>.
Yes. In this case, you must disable the errorHandler in the second route.

Here is a camel example showing that in action

https://svn.apache.org/repos/asf/camel/tags/camel-2.7.1/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionCallSubRouteNoErrorHandlerTest.java

Regards,

Charles Moulliard

Apache Committer

Blog : http://cmoulliard.blogspot.com
Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard
Skype: cmoulliard



2011/7/1 Zhemzhitsky Sergey <Se...@troika.ru>:
> Hi there,
>
> I'm wondering whether it is possible to propagate an exception to the parent route?
>
> My configuration is the following:
>
> <route id="parent">
>  <from uri="direct://parent"/>
>  <to uri="direct://child"/>
>  <onException>
>    <exception>org.test.MyException</exception>
>    <!-do something -->
>  </onException>
> </route>
>
> <route id="child">
>   <from uri=" direct://child"/>
>   <throwException ref="myException"/>
> </route>
>
> Is it possible to handle an exception thrown in the child route in the parent route?
>
> Best Regards,
> Sergey Zhemzhitsky
>
>
> _______________________________________________________
>
> The information contained in this message may be privileged and conf idential and protected from disclosure. If you are not the original intended recipient, you are hereby notified that any review, retransmission, dissemination, or other use of, or taking of any action in reliance upon, this information is prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and delete it from your computer. Thank you for your cooperation. Troika Dialog, Russia.
> If you need assistance please contact our Contact Center  (+7495) 258 0500 or go to www.troika.ru/eng/Contacts/system.wbp
>
>