Apache camel and <groovy> </groovy>

I want to modify file with groovy using:

 <from uri="file:/data/inbox?delete=true" />
    <transform>
    <groovy>
        body =  body[1..3]
    </groovy>
    </transform>
<to uri="file:/data/outbox"/>

I get an error:

groovy.lang.MissingMethodException: No signature of method: org.apache.camel.component.file.GenericFile.getAt() is applicable for argument types: (groovy.lang.IntRange) values: [1..3]

What am I doing wrong?

Upvotes: 0

Views: 486

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55555

Yes the input is file based and you attempt to use a groovy function that works on a list to grab the 1st to 3rd elements. You cannot do that. If you want to grab only the first 3 lines of a file, then you need to convert the message first to a list etc, or use the splitter eip to split the file line by line and group them together in a list which you can then afterwards do the groovy script

Upvotes: 1

Related Questions