user1723105
user1723105

Reputation: 121

Apache Camel: How do I signal to other processes that I moved/renamed a file?

I am trying to develop a file receipt process using Camel. what I am trying to do seems simple enough:

I have tried several different approaches but none seem to work exactly as I would like. My main issues are that since the file is not moved/renamed until the route is completed, I cannot signal to any downstream process that the file is available within that route.

I need to invoke webservices in order to determine the new name and location, once I do that the body is changed and I cannot use a file producer to move the file from within the route.

I would really appreciate hearing any other solutions.

Upvotes: 2

Views: 1755

Answers (2)

gregwhitaker
gregwhitaker

Reputation: 13410

You can signal the processing routes and then have them poll using the doneFile functionality of the file component.

Your first process will copy the files, signal the processing routes, and when it is done copying the file it will write a done file. Once the done file has been written the file consumers in your processing routes will pick up the file you want to process. This guarantees that the file is written before it is processed.

Check out the "Using done files" section of the file component.

http://camel.apache.org/file2.html

Upvotes: 1

Petter Nordlander
Petter Nordlander

Reputation: 22279

Using other components you could have used the OnCompletion DSL-syntax to trigger a post-route message for futher processing.

However, with the file component, this is not really doable, since the move/done thingy happends in parallell with that "OnCompletion" trigger, and you can't be sure that the file is really done.

You might have some luck with the Unit of Work API which can register post route execution logic (this is how the File component fires of the move when the route is done).

However, do you really need this logic? I see that you might want to send a wakeup call to some file consumer, but do the file really have to be ready that very millisec? Can't you just start to poll for the file and grab it once ready, once you received the trigger message? That's ususually how you do things with file based protocols (or just ignore the trigger and poll once every now and then).

Upvotes: 0

Related Questions