On Wed, May 15, 2013 at 5:06 AM, Willem jiang <willem.ji...@gmail.com> wrote:
> 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

Yes you can. The DSL has special support for that so it makes
converting from java <-> xml easier.
But you should not have ${ } etc just do as you would do in Java DSL

 <camel:setHeader headerName="Exchange.FILE_NAME">

When a key starts with Exchange. then Camel checks if its a field from
the Exchange interface and uses its value.



> <camel:setHeader headerName="CamelFileName"/>
> <camel:constant>request-${date:now:yyyy-MM-dd-HHmmssSSS}</camel:constant>
>

And btw use simple instead of constant. As constant is really just a
hardcoded fixed constant value. So if you want the current date, use
the simple language that has this function.

>
> --
> 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).
>
>
>



--
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to