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 2014/11/21 08:42:01 UTC
Camel Exception and Velocity - Blank Values
Hi
I have a route as follows which consumes from a vm: endpoint. Data comes to
this endpoint from an exception handler in another module.
I am trying to send alert mails for this exception using camel velocity.
I used both {in.headers.CAMEL_EXCEPTION} was well as ${exception} in the
camel veloctity template to populate the exception string. Both yeilds BLANK
output.
Can someone give me a clue.
Also looks like *<setHeader headerName="CAMEL_EXCEPTION ">
<simple>${exception}</simple>
</setHeader>* too doesnt work since I am trying to print header but again
no value :-(
Below is my route file!
* <route id="UTILITY_Multicasting">
<from uri="vm:Q_EXCEPTIONSTRATEGY" />
<setExchangePattern pattern="InOnly" />
<log message="Message from Exception Handler Module - Details :
${exception}"
loggingLevel="WARN" logName="ExceptionHandlerModule" />
<setHeader headerName="CAMEL_EXCEPTION ">
<simple>${exception}</simple>
</setHeader>
<log
message="CAMEL_EXCEPTION Header populated as
${in.header.CAMEL_EXCEPTION}"
loggingLevel="WARN" logName="ExceptionDetails" />
<multicast stopOnException="true">
<to uri="seda:EmailAlert" />
<to uri="seda:DBUpdate" />
</multicast>
</route>
<route id="UTILITY_AlertMails">
<from uri="seda:EmailAlert" />
<setExchangePattern pattern="InOnly" />
<log logName="ExceptionHandling" loggingLevel="INFO"
message="Exception received for TXN_NO ${in.header.TXN_ID}. Preparing
the Email Alert" />
<setHeader headerName="to">
<simple>{{alertEmailTo}}</simple>
</setHeader>
<setHeader headerName="CC">
<simple>{{alertEmailCC}}</simple>
</setHeader>
<setHeader headerName="from">
<simple>{{alertMailFrom}}</simple>
</setHeader>
<setHeader headerName="subject">
<simple>{{alertMailSubject}} - ${in.header.INTERFACE_ID} : TXN
${in.header.TXN_ID}</simple>
</setHeader>
<setHeader headerName="contentType">
<constant>text/plain</constant>
</setHeader>
<to
uri="velocity:file://D:/velocitytemplates/AlertMailFormat.vm?contentCache=true"
/>
<setHeader headerName="archivePath">
<simple>{{fuseArchivePath}}/${in.header.INTERFACE_NAME}</simple>
</setHeader>
<to uri="bean:AddAttachmentProcessor" />
<to uri="smtp://{{smtpServerUrl}}?mapMailMessage=true" />
</route>
*
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Exception-and-Velocity-Blank-Values-tp5759407.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel Exception and Velocity - Blank Values
Posted by Reji Mathews <co...@gmail.com>.
Wow !
Thanks Scott ! That just missed out my attention :)
It works now!
And along with that I also had go change ${exception} to
${exception.message}
Cheers brother!
Reji
On 21/11/2014 3:22 pm, "Scott Coleman" <sc...@empower-technology.com>
wrote:
> Have you tried without the space after the header name "CAMEL_EXCEPTION ".
>
> > On 21 Nov 2014, at 08:29, contactreji <co...@gmail.com> wrote:
> >
> > Thanx Claus for the tip.
> >
> > But I was wondering why my setHeader is not able to popuate the value
> >
> > <setHeader headerName="CAMEL_EXCEPTION ">
> > <simple>${exception}</simple>
> > </setHeader>
> >
> >
> > This doesnt work :-(
> >
> > Reji
> >
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Camel-Exception-and-Velocity-Blank-Values-tp5759407p5759414.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
Re: Camel Exception and Velocity - Blank Values
Posted by Scott Coleman <sc...@empower-technology.com>.
Have you tried without the space after the header name "CAMEL_EXCEPTION “.
> On 21 Nov 2014, at 08:29, contactreji <co...@gmail.com> wrote:
>
> Thanx Claus for the tip.
>
> But I was wondering why my setHeader is not able to popuate the value
>
> <setHeader headerName="CAMEL_EXCEPTION ">
> <simple>${exception}</simple>
> </setHeader>
>
>
> This doesnt work :-(
>
> Reji
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Exception-and-Velocity-Blank-Values-tp5759407p5759414.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel Exception and Velocity - Blank Values
Posted by contactreji <co...@gmail.com>.
Thanx Claus for the tip.
But I was wondering why my setHeader is not able to popuate the value
<setHeader headerName="CAMEL_EXCEPTION ">
<simple>${exception}</simple>
</setHeader>
This doesnt work :-(
Reji
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Exception-and-Velocity-Blank-Values-tp5759407p5759414.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel Exception and Velocity - Blank Values
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
A good idea is to check the unit tests of camel-velocity to see how
those templates are done there, this may help you.
On Fri, Nov 21, 2014 at 8:42 AM, contactreji <co...@gmail.com> wrote:
> Hi
>
> I have a route as follows which consumes from a vm: endpoint. Data comes to
> this endpoint from an exception handler in another module.
>
> I am trying to send alert mails for this exception using camel velocity.
>
> I used both {in.headers.CAMEL_EXCEPTION} was well as ${exception} in the
> camel veloctity template to populate the exception string. Both yeilds BLANK
> output.
>
> Can someone give me a clue.
>
> Also looks like *<setHeader headerName="CAMEL_EXCEPTION ">
> <simple>${exception}</simple>
> </setHeader>* too doesnt work since I am trying to print header but again
> no value :-(
>
>
> Below is my route file!
>
> * <route id="UTILITY_Multicasting">
>
> <from uri="vm:Q_EXCEPTIONSTRATEGY" />
> <setExchangePattern pattern="InOnly" />
>
> <log message="Message from Exception Handler Module - Details :
> ${exception}"
> loggingLevel="WARN" logName="ExceptionHandlerModule" />
>
> <setHeader headerName="CAMEL_EXCEPTION ">
> <simple>${exception}</simple>
> </setHeader>
>
> <log
> message="CAMEL_EXCEPTION Header populated as
> ${in.header.CAMEL_EXCEPTION}"
> loggingLevel="WARN" logName="ExceptionDetails" />
>
> <multicast stopOnException="true">
> <to uri="seda:EmailAlert" />
> <to uri="seda:DBUpdate" />
> </multicast>
> </route>
>
> <route id="UTILITY_AlertMails">
>
> <from uri="seda:EmailAlert" />
> <setExchangePattern pattern="InOnly" />
>
> <log logName="ExceptionHandling" loggingLevel="INFO"
> message="Exception received for TXN_NO ${in.header.TXN_ID}. Preparing
> the Email Alert" />
>
>
> <setHeader headerName="to">
> <simple>{{alertEmailTo}}</simple>
> </setHeader>
> <setHeader headerName="CC">
> <simple>{{alertEmailCC}}</simple>
> </setHeader>
> <setHeader headerName="from">
> <simple>{{alertMailFrom}}</simple>
> </setHeader>
> <setHeader headerName="subject">
> <simple>{{alertMailSubject}} - ${in.header.INTERFACE_ID} : TXN
> ${in.header.TXN_ID}</simple>
> </setHeader>
> <setHeader headerName="contentType">
> <constant>text/plain</constant>
> </setHeader>
> <to
>
> uri="velocity:file://D:/velocitytemplates/AlertMailFormat.vm?contentCache=true"
> />
> <setHeader headerName="archivePath">
> <simple>{{fuseArchivePath}}/${in.header.INTERFACE_NAME}</simple>
> </setHeader>
> <to uri="bean:AddAttachmentProcessor" />
> <to uri="smtp://{{smtpServerUrl}}?mapMailMessage=true" />
> </route>
> *
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Exception-and-Velocity-Blank-Values-tp5759407.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/