Reputation: 200
This Camel route should start reading files from a Ftp-Server:
from("sftp://user@...")
Now, I don't want this to start automatically, or polling, or similar. This should be started manually (externally, JMX). I have other routes which are being triggered via a MBean, and I use for that the direct label:
from("direct:myRoute1")
Which is the best way to do the same and starting as the first action with an FTP-read functionality? Something like:
from("direct:myRoute2")
.from("sftp://user@...")
.autoStartup(false)
? This is not working. After the manual-JMX-trigger no file is being ftp-read. I guess the two "from" starting the route work in parallel and therefore starting the "direct:myRoute2" does not trigger the FTP.
Kann I put the FTP-URI in another component, other than "from", to start the FTP-Read after the from("direct:myRoute2")?
BTW: This is an individual route, with no connection with other routes.
Thanks
Upvotes: 9
Views: 7164
Reputation: 820
What you need is Poll Enrich:
from("direct:myRoute2")
.pollEnrich("ftp://localhost")
.to("mock:result");
Now trigger the direct (no matter what you send to it) and the ftp consumer starts.
Upvotes: 8
Reputation: 55750
Read the documentation about how to configure routes to not auto start:
Then check out the control bus EIP which allows to start routes from other routes
And this FAQ talks about stopping a route, but starting would be similar
And there is also API on CamelContext to start route, or you can use JMX.
Upvotes: 7