camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem jiang <willem.ji...@gmail.com>
Subject Re: Problem from Java DSL to Spring DSL
Date Wed, 15 May 2013 03:06:42 GMT
Hi,

I think you cannot use the constant of Exchange.FILE_NAME directly in the Spring DSL.
You should use the String directly like this  
<camel:setHeader headerName="CamelFileName"/>
<camel:constant>request-${date:now:yyyy-MM-dd-HHmmssSSS}</camel:constant>


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Wednesday, May 15, 2013 at 10:40 AM, Gary Liu wrote:

> Hello,
>  
> I am trying to translate the following Java DSL (This is the example from
> 2.10.4). The Java DSL works fine. But I after I translate to Spring DSL,
> several things are not working as expected. Would someone please help?
> ================================Java DSL=======================
> from("cxf:bean:reportIncident")
> .convertBodyTo(InputReportIncident.class)
> .setHeader(Exchange.FILE_NAME,
> constant("request-${date:now:yyyy-MM-dd-HHmmssSSS}"))
> .wireTap("file://target/inbox/")
> .choice().when(simple("${body.givenName} == 'Claus'"))
> .transform(constant(ok))
> .otherwise()
> .bean(new ReportIncidentImpl(), "doReportIncident")
> .transform(constant(accepted)
>  
> );
>  
> ===========================SPRING DSL===================
> <camel:camelContext id="camel">
>  
>  
> <camel:route>
> <camel:from uri="cxf:bean:reportIncident" />
> <camel:convertBodyTo
> type="org.apache.camel.example.reportincident.InputReportIncident" />
> <camel:setHeader headerName="${Exchange.FILE_NAME}">
>  
> <camel:constant>request-${date:now:yyyy-MM-dd-HHmmssSSS}</camel:constant>
> </camel:setHeader>
> <camel:wireTap uri="file://target/inbox/"></camel:wireTap>
> <camel:choice>
> <camel:when>
> <camel:simple>${body.givenName} == 'Claus'</camel:simple>
> <camel:transform>
> <camel:constant>"OK"</camel:constant>
> </camel:transform>
> </camel:when>
> <camel:otherwise>
> <camel:transform>
> <camel:constant>"Accepted"</camel:constant>
> </camel:transform>
> </camel:otherwise>
> </camel:choice>
> </camel:route>
> </camel:camelContext>
> ===========================================================
>  
> Here are the things I did not translate propertly:
>  
> .choice().when(simple("${body.givenName} == 'Claus'"))
> .transform(constant(ok))
>  
> NOT THE SAME AS:
> <camel:choice>
> <camel:when>
> <camel:simple>${body.givenName} == 'Claus'</camel:simple>
> <camel:transform>
> <camel:constant>"OK"</camel:constant>
> </camel:transform>
> </camel:when>
>  
>  
> .setHeader(Exchange.FILE_NAME,
> constant("request-${date:now:yyyy-MM-dd-HHmmssSSS}"))
>  
> NOT THE SAME AS:
>  
> <camel:setHeader headerName="${Exchange.FILE_NAME}">
> <camel:constant>request-${date:now:yyyy-MM-dd-HHmmssSSS}
>  
> Thanks,
> --Gary
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-from-Java-DSL-to-Spring-DSL-tp5732558.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Mime
View raw message