shyamsrd
shyamsrd

Reputation: 49

Apache camel how to send file name from one router file component to another router file component

I hava file1.jpg,file2.jpg,file3.jpg in DirA. I have file1.json,file2.json,file3.json in DirB

How can I create a apache camel file route such that first route picks file1.jpg from a DirA , processes and pass file1 name to second route so that it can read file1.json and processes.

CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
            public void configure() {
from("file:///DirA/?noop=true"). bean(MyBean.class,"doSomeThingWithJPG(${file:absolute.path})").

from("file:///DirB/?noop=true&fileName=${file:name}.json").
bean(AnotherBean.class,"doSomeThingWithJSON(${file:absolute.path})") ;
    } 
 }) 

The second from (file:///) component is also pointing to file in DirA instead of files in DirB

Upvotes: 0

Views: 746

Answers (1)

Darius X.
Darius X.

Reputation: 2937

You could:

  • Stage the JSON file
  • Write a processor or bean that copies a named file from one directory to another
  • Call that processor after processing JPG, to copy the JSON to another directory
  • Have the second file-listener polling that other directory

enter image description here

Upvotes: 1

Related Questions