You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by gazetaj <ga...@gmail.com> on 2014/05/09 17:03:57 UTC

Camel Scripting questions - may some of you can help

I am trying to user camel scripting for both a completion predicate, as well
as setting some header info I 
need for posterior use.

Added to the POM the following:

...2.13.0
...
    org.apache.camel
    camel-script
    ${camel-version}
  


withing a router - I could setup the info directly as a string - something
like this:
.setHeader("thisIsTest", simple("${body.toString().substring(16, 25)}"))
which for posterior use I saved as part of the name since the routes produce
files...

After which I am trying to retrieve the information, as an example - the
file name would be 
test.info1.info2.info3.info4.dat

then I have tried the following:
--javascript
.setHeader("AAOriginalFileName").javaScript("(request.getHeader('camelfilenameonly')).toString().split('.')[0]")

--groovy
.setHeader("AAOriginalFileName").groovy("(properties.resolve(request.getHeader('camelfilenameonly')).toString().split('.')[0]")

-- the javascript one returns me null unless I remove the split() from the
codethen it returns me the string I am looking for but I can seem to split
it - even though using Chrome and the
 script console I am able to emulate the code behaviour I am aiming for.
Within camel I don't seem
 to find a solution. 

-- the groovy one - generates the follwoing message

org.apache.camel.FailedToCreateRouteException: Failed to create route
2_SegmentedFile at: >>> 
SetHeader[AAOriginalFileName, 
groovy{(properties.resolve(request.getHeader('camelfilenameonly')).toString().split('.')).toString()}]
 <<< in route:
Route(2_SegmentedByDuns)[[From[file:Inbound/GroupedByDunsSeg... because of
No script engine could be created for: groovy
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:910)
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:175)
	at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:778)
	at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2041)
	... 37 more



My questions are:
Does Simple language has a Split?
Am I missing something?
Do I need to declare on the POM any dependencies - groovy or rhino?
Are there alternatives to create this behaviour?


thank you in advance for your time.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Scripting-questions-may-some-of-you-can-help-tp5750964.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Scripting questions - may some of you can help

Posted by Shiv <sh...@gmail.com>.
You might need to add camel-groovy jar to your POM to get rid of this
exception.

Thanks
Shiv



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Scripting-questions-may-some-of-you-can-help-tp5750964p5750967.html
Sent from the Camel - Users mailing list archive at Nabble.com.