You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by contactreji <co...@gmail.com> on 2015/04/01 00:38:58 UTC

camel - exception handling

Hi
Am trying to catch an exception and based on that continue the flow. Using
below code. But on xml validation I get following 
cvc-complex-type.2.4.a: Invalid content was found starting with element
'camel:continued'. One of
'{"http://camel.apache.org/schema/spring":exception,
"http://camel.apache.org/schema/spring":onWhen, "http://camel.apache.org/
 schema/spring":handled, "http://camel.apache.org/schema/spring":aop,
"http://camel.apache.org/schema/spring":aggregate,
"http://camel.apache.org/schema/spring":bean,
"http://camel.apache.org/schema/spring":doCatch, "http://
 camel.apache.org/schema/spring":when,
"http://camel.apache.org/schema/spring":choice,
"http://camel.apache.org/schema/spring":otherwise,
"http://camel.apache.org/schema/spring":convertBodyTo,
"http://camel.apache.org/
 schema/spring":delay,
"http://camel.apache.org/schema/spring":dynamicRouter,
"http://camel.apache.org/schema/spring":enrich,
"http://camel.apache.org/schema/spring":filter,
"http://camel.apache.org/schema/spring":doFinally, 
 "http://camel.apache.org/schema/spring":idempotentConsumer,
"http://camel.apache.org/schema/spring":inOnly,
"http://camel.apache.org/schema/spring":inOut,
"http://camel.apache.org/schema/spring":intercept, "http://
 camel.apache.org/schema/spring":interceptFrom,
"http://camel.apache.org/schema/spring":interceptSendToEndpoint,
"http://camel.apache.org/schema/spring":loadBalance,
"http://camel.apache.org/schema/spring":log, "http://
 camel.apache.org/schema/spring":loop,
"http://camel.apache.org/schema/spring":marshal,
"http://camel.apache.org/schema/spring":multicast,
"http://camel.apache.org/schema/spring":onCompletion,
"http://camel.apache.org/
 schema/spring":onException,
"http://camel.apache.org/schema/spring":pipeline,
"http://camel.apache.org/schema/spring":policy,
"http://camel.apache.org/schema/spring":pollEnrich,
"http://camel.apache.org/schema/
 spring":process, "http://camel.apache.org/schema/spring":recipientList,
"http://camel.apache.org/schema/spring":removeHeader,
"http://camel.apache.org/schema/spring":removeHeaders,
"http://camel.apache.org/schema/
 spring":removeProperties,
"http://camel.apache.org/schema/spring":removeProperty,
"http://camel.apache.org/schema/spring":resequence,
"http://camel.apache.org/schema/spring":rollback,
"http://camel.apache.org/schema/
 spring":route, "http://camel.apache.org/schema/spring":routingSlip,
"http://camel.apache.org/schema/spring":sample,
"http://camel.apache.org/schema/spring":setBody,
"http://camel.apache.org/schema/spring":setExchangePattern, 
 "http://camel.apache.org/schema/spring":setFaultBody,
"http://camel.apache.org/schema/spring":setHeader,
"http://camel.apache.org/schema/spring":setOutHeader,
"http://camel.apache.org/schema/spring":setProperty, "http://
 camel.apache.org/schema/spring":sort,
"http://camel.apache.org/schema/spring":split,
"http://camel.apache.org/schema/spring":stop,
"http://camel.apache.org/schema/spring":threads,
"http://camel.apache.org/schema/
 spring":throttle, "http://camel.apache.org/schema/spring":throwException,
"http://camel.apache.org/schema/spring":to,
"http://camel.apache.org/schema/spring":transacted,
"http://camel.apache.org/schema/spring":transform, 
 "http://camel.apache.org/schema/spring":doTry,
"http://camel.apache.org/schema/spring":unmarshal,
"http://camel.apache.org/schema/spring":validate,
"http://camel.apache.org/schema/spring":whenSkipSendToEndpoint, "http://
 camel.apache.org/schema/spring":wireTap,
"http://camel.apache.org/schema/spring":restBinding}' is expected.




*<doTry>
						<camel:unmarshal ref="xmljsonWithOptions" />
						<doCatch>
							<camel:exception>net.sf.json.JSONException</camel:exception>
							<camel:continued>
								<camel:constant>true</camel:constant>
							</camel:continued>
						</doCatch>
						<doFinally>
							<camel:log logName="Redknee-ib-NTTInterface"
								loggingLevel="INFO"
								message="Wrong 
						JSON String. Continuing the flow still.." />
						</doFinally>
					</doTry>*


How can we fix this?

Cheers
Reji



-----
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
--
View this message in context: http://camel.465427.n5.nabble.com/camel-exception-handling-tp5765089.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel - exception handling

Posted by yogu13 <yo...@gmail.com>.
Hello Jack,

if handled is set to "false" then the exception is not handled, so it will
be stored as an exception on the exchange and break out from the route.

Continued should be available for use, Not sure why isnt it working in your
case.. can you upgrade to latest and check if you still get the issue?


Regards,
-Yogesh



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

Re: camel - exception handling

Posted by Andrew Block <an...@gmail.com>.
Nothing seems to jump out.

Would you be able to share you entire camel context?

Thanks

-- 
Andrew Block


On June 24, 2015 at 3:21:30 PM, jackkirsten (jkfriends@hotmail.com) wrote:

Hi Andrew,  

I'm also hitting the same exception. If <continued> is available to use, why  
is not working? This is what I have and Camel doesn't seem to be happy with  
it. I want to log the error and move on with the route rather than stopping  
the flow. If I set Handled = false, wouldn't it break the flow?  

<onException>  
<exception>java.lang.Exception</exception>  
<continued><constant>true</constant></continued>  
<log message="*** Message: ${exception.message} ***" />  
<log message="${exception.stacktrace}" />  
</onException>  

How do I make the continued to work fine? I'm using Came 2.9.2.  

Thanks.  



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

Re: camel - exception handling

Posted by jackkirsten <jk...@hotmail.com>.
Hi Andrew,

I'm also hitting the same exception. If <continued> is available to use, why
is not working?  This is what I have and Camel doesn't seem to be happy with
it.  I want to log the error and move on with the route rather than stopping
the flow.  If I set Handled = false, wouldn't it break the flow?

			<onException>
			    <exception>java.lang.Exception</exception>
			    <continued><constant>true</constant></continued>
			    <log message="*** Message: ${exception.message} ***" />
			    <log message="${exception.stacktrace}" />
			</onException>

How do I make the continued to work fine?  I'm using Came 2.9.2.

Thanks.



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

Re: camel - exception handling

Posted by Andrew Block <an...@gmail.com>.
Continued is not a valid option in the catch block. By default the route will continue since it is the assumption that the catch logic will handle any any failures and continue. You can set the <camel:handled>false</camel:handled> if you want to propagate the exception.

- Andy

-- 
Andrew Block
M: (716) 870-2408

On March 31, 2015 at 5:39:27 PM, contactreji (contactreji@gmail.com) wrote:

Hi  
Am trying to catch an exception and based on that continue the flow. Using  
below code. But on xml validation I get following  
cvc-complex-type.2.4.a: Invalid content was found starting with element  
'camel:continued'. One of  
'{"http://camel.apache.org/schema/spring":exception,  
"http://camel.apache.org/schema/spring":onWhen, "http://camel.apache.org/  
schema/spring":handled, "http://camel.apache.org/schema/spring":aop,  
"http://camel.apache.org/schema/spring":aggregate,  
"http://camel.apache.org/schema/spring":bean,  
"http://camel.apache.org/schema/spring":doCatch, "http://  
camel.apache.org/schema/spring":when,  
"http://camel.apache.org/schema/spring":choice,  
"http://camel.apache.org/schema/spring":otherwise,  
"http://camel.apache.org/schema/spring":convertBodyTo,  
"http://camel.apache.org/  
schema/spring":delay,  
"http://camel.apache.org/schema/spring":dynamicRouter,  
"http://camel.apache.org/schema/spring":enrich,  
"http://camel.apache.org/schema/spring":filter,  
"http://camel.apache.org/schema/spring":doFinally,  
"http://camel.apache.org/schema/spring":idempotentConsumer,  
"http://camel.apache.org/schema/spring":inOnly,  
"http://camel.apache.org/schema/spring":inOut,  
"http://camel.apache.org/schema/spring":intercept, "http://  
camel.apache.org/schema/spring":interceptFrom,  
"http://camel.apache.org/schema/spring":interceptSendToEndpoint,  
"http://camel.apache.org/schema/spring":loadBalance,  
"http://camel.apache.org/schema/spring":log, "http://  
camel.apache.org/schema/spring":loop,  
"http://camel.apache.org/schema/spring":marshal,  
"http://camel.apache.org/schema/spring":multicast,  
"http://camel.apache.org/schema/spring":onCompletion,  
"http://camel.apache.org/  
schema/spring":onException,  
"http://camel.apache.org/schema/spring":pipeline,  
"http://camel.apache.org/schema/spring":policy,  
"http://camel.apache.org/schema/spring":pollEnrich,  
"http://camel.apache.org/schema/  
spring":process, "http://camel.apache.org/schema/spring":recipientList,  
"http://camel.apache.org/schema/spring":removeHeader,  
"http://camel.apache.org/schema/spring":removeHeaders,  
"http://camel.apache.org/schema/  
spring":removeProperties,  
"http://camel.apache.org/schema/spring":removeProperty,  
"http://camel.apache.org/schema/spring":resequence,  
"http://camel.apache.org/schema/spring":rollback,  
"http://camel.apache.org/schema/  
spring":route, "http://camel.apache.org/schema/spring":routingSlip,  
"http://camel.apache.org/schema/spring":sample,  
"http://camel.apache.org/schema/spring":setBody,  
"http://camel.apache.org/schema/spring":setExchangePattern,  
"http://camel.apache.org/schema/spring":setFaultBody,  
"http://camel.apache.org/schema/spring":setHeader,  
"http://camel.apache.org/schema/spring":setOutHeader,  
"http://camel.apache.org/schema/spring":setProperty, "http://  
camel.apache.org/schema/spring":sort,  
"http://camel.apache.org/schema/spring":split,  
"http://camel.apache.org/schema/spring":stop,  
"http://camel.apache.org/schema/spring":threads,  
"http://camel.apache.org/schema/  
spring":throttle, "http://camel.apache.org/schema/spring":throwException,  
"http://camel.apache.org/schema/spring":to,  
"http://camel.apache.org/schema/spring":transacted,  
"http://camel.apache.org/schema/spring":transform,  
"http://camel.apache.org/schema/spring":doTry,  
"http://camel.apache.org/schema/spring":unmarshal,  
"http://camel.apache.org/schema/spring":validate,  
"http://camel.apache.org/schema/spring":whenSkipSendToEndpoint, "http://  
camel.apache.org/schema/spring":wireTap,  
"http://camel.apache.org/schema/spring":restBinding}' is expected.  




*<doTry>  
<camel:unmarshal ref="xmljsonWithOptions" />  
<doCatch>  
<camel:exception>net.sf.json.JSONException</camel:exception>  
<camel:continued>  
<camel:constant>true</camel:constant>  
</camel:continued>  
</doCatch>  
<doFinally>  
<camel:log logName="Redknee-ib-NTTInterface"  
loggingLevel="INFO"  
message="Wrong  
JSON String. Continuing the flow still.." />  
</doFinally>  
</doTry>*  


How can we fix this?  

Cheers  
Reji  



-----  
Reji Mathews  
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )  
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a  
Twitter - reji_mathews  
--  
View this message in context: http://camel.465427.n5.nabble.com/camel-exception-handling-tp5765089.html  
Sent from the Camel - Users mailing list archive at Nabble.com.