You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by TonyK <ak...@sfgmembers.com> on 2013/04/25 23:49:32 UTC

Null Body

I have two routes, the parent route uses jms with the inout EIP to call the
below route, and uses the transferException parameter so that exceptions get
returned to the parent route. The problem is that in my child route I
unmarshal using jaxb before calling a bean, when an exceptions occurs in
that bean and the exception returns to the parent route the body is always
null. I've tried using the useOriginalMessage in the onException element,
but the body is still null when returned to the parent. If more information
is required, please let me know.

Thank you,
Tony

		<onException useOriginalMessage="true">
			<exception>java.lang.Exception</exception>
			<redeliveryPolicy maximumRedeliveries="1"
				backOffMultiplier="2" useExponentialBackOff="true" />
		</onException>
		
		<route id="ImagingRoute">
			<from uri="{{endpoint.ImagingQueue}}" />
			<unmarshal ref="jaxb" />
			<to uri="{{endpoint.ImagingService}}" />
			<marshal ref="jaxb" />
		</route>



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

Re: Null Body

Posted by TonyK <ak...@sfgmembers.com>.
Thanks for the quick response. I tried setting streamcache to true on the
route, but no luck. I believe it has something to do with the unmarshalling
to jaxb, if I throw an exception before the unmarshal, then the body
returned to the parent route is not null. If add a processor to my
onException, then I see data in the body, but I can't seem to pass it back
so that when I get to my aggregation strategy the data is gone... I've put
the routes below to try to give a little more context.


	<camelContext xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="defaultHandler" >
	
		<errorHandler id="defaultHandler" type="DefaultErrorHandler">
			<redeliveryPolicy redeliveryDelay="1000" maximumRedeliveries="0" />
		</errorHandler>
		
		<route id="REMOVETestEnvironmentWriteToQueue">
			<from uri="file:C:\\test\\from\\?noop=true&delay=40000" />
			<to uri="jms:ANN.NB.ILLUST.BATCH" />
		</route>
		
		<route id="IllustrationsBatch">
			<from uri="jms:ANN.NB.ILLUST.BATCH" />
			<camel:split strategyRef="IllustAggregationStrat"
parallelProcessing="true">
				<xpath>/TXLife/TXLifeRequest</xpath>

				<to uri="xslt:WrapTXLifeRequestInTXLife.xsl" />
				<inOut uri="jms:ANN.NB.ILLUST.INSURANCETECH.IN?           
                                                transferException=true
                                                &requestTimeout=120000" />
///This route is just calling a bean that returns xml from a file.

				<setHeader headerName="formDestination">
                                         
<constant>{{formInstanceRequest.imagingFormPath}}</constant>
                                </setHeader>
				<to uri="xslt:InsTechResultToFormRequest.xsl" />
				<inOut uri="jms:ANN.NB.ILLUST.IMAGE.IN?transferException=true
                                                                                     
&requestTimeout=120000" />
				
			</camel:split>
		</route>
	</camelContext>

----------------------------------------------------------------------------------
	<camelContext xmlns="http://camel.apache.org/schema/spring">
		<dataFormats>
			<jaxb id="jaxb" contextPath="com.sfg.annuity.model.acord" />
		</dataFormats>

		<onException>
			<exception>java.lang.Exception</exception>
			<redeliveryPolicy maximumRedeliveries="1"
				backOffMultiplier="2" useExponentialBackOff="true" />
		</onException>

		<route id="ImagingRoute">
			<from
uri="jms:ANN.NB.ILLUST.IMAGE.IN?transferException=true&requestTimeout=120000"
/>
			<unmarshal ref="jaxb" /> 
			<to uri="{{endpoint.ImagingService}}" /> // This is just calling a bean
that throws an IOException
			<marshal ref="jaxb" />
		</route>
	</camelContext>



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

Re: Exception in second inOut jms endpoint returns null body to aggregation strategy

Posted by TonyK <ak...@sfgmembers.com>.
I've trimmed my code to the bear minimum. If I throw the exception in my
first call to the child route, then I get the body returned to my
aggregation strategy, but when I throw an exception on my second call the
body is null when I get to the aggregation strategy. Why would this be?

--------------------------------------------------------------------
Main Route
--------------------------------------------------------------------
	<camelContext xmlns="http://camel.apache.org/schema/spring"
		errorHandlerRef="defaultHandler">

		<errorHandler id="defaultHandler" type="DeadLetterChannel"
			deadLetterUri="smtp://localhost:8059?to=mrr@aaaa.com&subject=Complete" />

		<route id="REMOVETestEnvironmentWriteToQueue">
			<from uri="{{endpoint.IncomingRequest}}" />
			<to uri="jms:ANN.NB.ILLUST.BATCH" />
		</route>

		<route id="IllustrationsBatch">
			<from uri="jms:ANN.NB.ILLUST.BATCH" />
			<camel:split strategyRef="IllustAggregationStrat"
				parallelProcessing="false">
				<xpath>/TXLife/TXLifeRequest</xpath>

*If I throw an exception on the first call to the child route, then my error
handler will send me an email with the body of "Test" and when I reach my
aggregation strategy the body also says "Test". Which is what I would
expect.*
				<transform><camel:simple>Test</camel:simple></transform>
				<inOut
uri="jms:ANN.NB.ILLUST.IMAGE.IN?transferException=true&requestTimeout=120000"
/>

*If I throw an exception on the second call to the child route, then my
error handler will send me an email with the body of "Test2", but when I
reach my aggregation strategy the body is null.*
				<transform><camel:simple>Test2</camel:simple></transform>
				<inOut
uri="jms:ANN.NB.ILLUST.IMAGE.IN?transferException=true&requestTimeout=120000"
/>

			</camel:split>
		</route>

	</camelContext>

--------------------------------------------------------------------------------------
Child route
--------------------------------------------------------------------------------------
	<camelContext xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="defaultHandler">
		<errorHandler id="defaultHandler" type="NoErrorHandler" />

		<route id="ImagingRoute">
			<from
uri="jms:ANN.NB.ILLUST.IMAGE.IN?transferException=true&requestTimeout=120000"
/>
			<to uri="bean:fakeImageCall" />
		</route>

	</camelContext>

------------------------------------------------------------------------------------------------------
Bean
----------------------------------------------------------------------------------------------
public class ImageServiceCall {

	public void process(Exchange exchange) throws Exception {
		if(exchange.getIn().getBody(String.class).equals("Test2")){
			throw new IOException();
		}
	}
}



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

Re: Null Body

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

Sounds like this FAQ
http://camel.apache.org/why-is-my-message-body-empty.html

On Thu, Apr 25, 2013 at 11:49 PM, TonyK <ak...@sfgmembers.com> wrote:
> I have two routes, the parent route uses jms with the inout EIP to call the
> below route, and uses the transferException parameter so that exceptions get
> returned to the parent route. The problem is that in my child route I
> unmarshal using jaxb before calling a bean, when an exceptions occurs in
> that bean and the exception returns to the parent route the body is always
> null. I've tried using the useOriginalMessage in the onException element,
> but the body is still null when returned to the parent. If more information
> is required, please let me know.
>
> Thank you,
> Tony
>
>                 <onException useOriginalMessage="true">
>                         <exception>java.lang.Exception</exception>
>                         <redeliveryPolicy maximumRedeliveries="1"
>                                 backOffMultiplier="2" useExponentialBackOff="true" />
>                 </onException>
>
>                 <route id="ImagingRoute">
>                         <from uri="{{endpoint.ImagingQueue}}" />
>                         <unmarshal ref="jaxb" />
>                         <to uri="{{endpoint.ImagingService}}" />
>                         <marshal ref="jaxb" />
>                 </route>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Null-Body-tp5731568.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
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: Null Body

Posted by TonyK <ak...@sfgmembers.com>.
After further analysis I've decided it has nothing to do with the marshalling
and unmarhalling. In my main route inside the split I make to inout calls,
if an exception is thrown in the second inout call, then I loose the body. I
can swap the two and it always happens in the second one.



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