0

I currently have a route which is triggered by the arrival of a file in a specific folder. The file then is parsed using Bindy DataFormat and the resulting objects processed by myProcessor:

from(inboundFile)
    .log("Processing: ${file:name}")
    .unmarshal(bindy)
    .process(myProcessor)
    .end()

Now I want to change the route so it's a direct route triggered by a restful. Is there a way I can keep using Bindy for parsing the file or do I have to write my own parser/unmarshal in a custom processor?

from("direct:myRoute")
    .log("Processing file")
    // What can I do here other than writing my own processor that loads and processes the file?>
    .unmarshal(bindy)
    .process(myProcessor)
    .end()
Gep
  • 848
  • 13
  • 29
  • 1
    I don't understand what you're trying to do. Do you mean that the route should be triggered by an "empty" REST call or will the file be sent via REST? It currently doesn't make any sense using `direct` as your from-endpoint unless this route is receiving from a different route. Please update your question to make it more clear, and explain why you think that you need to perform some special processing in order to use `bindy`. – Erik Karlstrand Jan 03 '18 at 12:45
  • 1
    Look at the Content Enricher EIP pattern where you can use pollEnrich to read the file – Claus Ibsen Jan 03 '18 at 14:02
  • Yes, the route should be triggered by an "empty" REST call. I'll look into the Content Enricher EIP thank you Claus – Gep Jan 03 '18 at 14:55
  • Ok, then the Content Enricher EIP should be exactly what you should be looking at, as @ClausIbsen said. – Erik Karlstrand Jan 03 '18 at 15:14
  • Sorry guys, I'm still struggling with this. Are there examples online of the pollEnrich? I can't find any. – Gep Feb 02 '18 at 15:03
  • I've added the pollEnrich().simple("file://myFolder&fileName=${in.body}") just before unmarshal(bindy). The pollEnrich picks up the correct file, but then it passes null to unmarshal causing the exception: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: null to the required type: java.io.InputStream with value null – Gep Feb 02 '18 at 15:08
  • Sorry, I found what the problem was, I used & instead of ? ...still if you have suggestions on where I can find working examples that would be useful. Thank you! – Gep Feb 02 '18 at 15:59

0 Answers0