camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allan C." <allan...@gmail.com>
Subject Re: Synchronizing SFTP and ActiveMQ
Date Thu, 11 May 2017 23:36:30 GMT
I'm not sure but perhaps the enrich pattern could work?

http://camel.apache.org/content-enricher.html

Regards, Allan.

Sent from Gmail mobile.

On 12 May 2017 07:12, "jgewehr" <jgewehr@gmail.com> wrote:

I'm not sure if I'm thinking about this problem correctly so please provide
any feedback you think is appropriate.  Also, I hope I'm not asking a
duplicate question but I've looked around quite a bit and haven't exactly
found anything that addresses this situation.

I'm using camel 2.17.

I'm planning to have 2 routes: an ActiveMQ route and an SFTP route.  I have
a python script that
    1) generates a file that needs to be SFTP'd to a server if needed
(sometimes there is no file), and then
    2) generates a json that is fed into the ActiveMQ route.  The process
that parses the json on the other end will do something with the SFTP
payload, if it exists.

The routes I'm thinking of implementing will look something like this:
SFTP route:
from("file:sftp_out_dir")
    .to("sftp://ip:port etc....");

ActiveMQ route:
from("file:amq_out_dir")
    .to"activemq:queue:myqueue)

The problem that I see is that there is a potential race condition here,
where the AMQ message arrives before the SFTP transfer is completed and the
process that parses the JSON on the other end then errors because the file
that it is expecting is not there.  How can I prevent this race condition?
The python script that is generating these files doesn't know anything about
camel, it is just generating files and dropping them into directories on the
file system.  So far this integration of python and camel has worked really
well for us because each operation was serial, but now we're trying to
simultaneously send a file on one route and a control message on another
route.

One solution that makes sense to me but I think isn't supported by camel
would be something like a nested route like this:

from(file:amq_out_dir)
        .from(file:sftp_out_dir)
        .to(sftp)
    .to(activemq)

So even though that's not actually a thing you can do with Camel, that is
the behavior I want, i.e. drop the json file into the amq_out_dir, transfer
the file over SFTP if it exists, wait for the SFTP transfer to complete,
then deliver the AMQ message.  Am I thinking about this problem in the wrong
way?  What is the best way to solve this problem with Camel?

Thanks in advance for any advice.



--
View this message in context: http://camel.465427.n5.nabble.
com/Synchronizing-SFTP-and-ActiveMQ-tp5799345.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message