Re: onException - properties and headers are lost

2018-06-05 Thread Balazs Szeti
Hi Reji,

You can use useOriginalMessage()

in onException to restore the original message body you received at from().
Like this:
onException(java.net.SocketException.class)
.useOriginalMessage()
.handled(true)
...
If the original message body was a stream you should enable stream caching
 on the route
(from("...").streamCaching()) or on the Camel Context.

Also there might be another problem with your route as exchange properties
should be available within onException(). Message headers are a bit
different as the endpoints called during the route modifies them a lot, but
if you store something in an exchange property at the beginning, it should
be available in onException.

Can you share the whole route and the storeOriginalPayloadInDb processor?
Which Camel version do you use exactly?

Regards,
Balazs

On Tue, Jun 5, 2018 at 2:29 AM Reji Mathews  wrote:

> Hi guys
>
> I have a business requirement where if an api call fails, I need to store
> the payload in a database for future retry.
>
> I have an onException clause like this
>
> onException(java.net.SocketException.class)
> .handled(true)
> .maximumRedeliveries(3)
> .log("Records are dropping due to excessing number of socket
> connections created. Dropping DPCI : ${property.dpci} , TCIN :
> ${property.tcin}")
> .to("log:MYAUDIT_2?showAll=true")
> .process(storeOriginalPayloadInDb)
> .end();
>
>
> I have added a property called "originalPayload" containing the received
> data. I want it to access the property in processor "
> *storeOriginalPayloadInDb*"
>
> I get NullPointorException accessing the property "originalPayload" ,
> reason being all headers and properties of the original exchange are lost
> by the time flow comes to onException block.
>
> What is the way I can achieve my requirement?
>
> Cheers
>


onException - properties and headers are lost

2018-06-04 Thread Reji Mathews
Hi guys

I have a business requirement where if an api call fails, I need to store
the payload in a database for future retry.

I have an onException clause like this

onException(java.net.SocketException.class)
.handled(true)
.maximumRedeliveries(3)
.log("Records are dropping due to excessing number of socket
connections created. Dropping DPCI : ${property.dpci} , TCIN :
${property.tcin}")
.to("log:MYAUDIT_2?showAll=true")
.process(storeOriginalPayloadInDb)
.end();


I have added a property called "originalPayload" containing the received
data. I want it to access the property in processor "
*storeOriginalPayloadInDb*"

I get NullPointorException accessing the property "originalPayload" ,
reason being all headers and properties of the original exchange are lost
by the time flow comes to onException block.

What is the way I can achieve my requirement?

Cheers