camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gazetaj <gaze...@gmail.com>
Subject Camel Scripting questions - may some of you can help
Date Fri, 09 May 2014 15:03:57 GMT
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.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message