You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by boden <bo...@gmail.com> on 2009/12/03 17:47:04 UTC

Using Camel to "route" binary files

I need to watch a folder for incoming binary files.  When one appears, I need
to examine it to determine where the file is to be sent.  I then need to
send the file to one or more "recipients" which may include a network share,
email, webdav, and a web service.  It may go to one, multiple, or all of
these destinations.  In some cases, where it ends up will also be dynamic,
such as the path on a network share (e.g. I know the base share at
configuration time, but ultimate path the file is copied to will be
dynamic).

Is this something that I can do with relative ease in Camel?  If so, can you
help get me started?

I realize that ESB-like products such as Camel may not be a perfect fit for
this scenario, but Camel has so many of the features I need already built
in...seems like it might be better than writing from scratch.
-- 
View this message in context: http://old.nabble.com/Using-Camel-to-%22route%22-binary-files-tp26629157p26629157.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using Camel to "route" binary files

Posted by Stan Lewis <ga...@gmail.com>.
I think Camel should work perfectly for you for this.  Have you
checked out the documentation on the camel-file endpoint here -
http://camel.apache.org/file2.html?  It's pretty exhaustive with a lot
of examples that should get you going in the right direction.

Also note that the camel Java and Spring maven archetypes set you up
with a really simple route that moves XML files:

http://camel.apache.org/camel-maven-archetypes.html

On Thu, Dec 3, 2009 at 11:47 AM, boden <bo...@gmail.com> wrote:
>
> I need to watch a folder for incoming binary files.  When one appears, I need
> to examine it to determine where the file is to be sent.  I then need to
> send the file to one or more "recipients" which may include a network share,
> email, webdav, and a web service.  It may go to one, multiple, or all of
> these destinations.  In some cases, where it ends up will also be dynamic,
> such as the path on a network share (e.g. I know the base share at
> configuration time, but ultimate path the file is copied to will be
> dynamic).
>
> Is this something that I can do with relative ease in Camel?  If so, can you
> help get me started?
>
> I realize that ESB-like products such as Camel may not be a perfect fit for
> this scenario, but Camel has so many of the features I need already built
> in...seems like it might be better than writing from scratch.
> --
> View this message in context: http://old.nabble.com/Using-Camel-to-%22route%22-binary-files-tp26629157p26629157.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Re: Using Camel to "route" binary files

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Dec 3, 2009 at 6:45 PM, boden <bo...@gmail.com> wrote:
>
> Excellent, thank you very much!
>
> I must say that getting two replies so quickly gives me a lot of confidence
> in this project.
>

Yeah its a great project.

See if we can keep it up for your next question

Btw you could do all this in a single POJO with a few annotations

See the POJO routing example
http://camel.apache.org/pojo-messaging-example.html

It requires camel-spring to work as its the one injecting the annotations stuff.



>
> Claus Ibsen-2 wrote:
>>
>> On Thu, Dec 3, 2009 at 5:47 PM, boden <bo...@gmail.com> wrote:
>>>
>>> I need to watch a folder for incoming binary files.  When one appears, I
>>> need
>>> to examine it to determine where the file is to be sent.  I then need to
>>> send the file to one or more "recipients" which may include a network
>>> share,
>>> email, webdav, and a web service.  It may go to one, multiple, or all of
>>> these destinations.  In some cases, where it ends up will also be
>>> dynamic,
>>> such as the path on a network share (e.g. I know the base share at
>>> configuration time, but ultimate path the file is copied to will be
>>> dynamic).
>>>
>>> Is this something that I can do with relative ease in Camel?  If so, can
>>> you
>>> help get me started?
>>>
>>
>> Yes it is in fact.
>>
>> You want to take a look at the dynamic recipient list EIP
>> http://camel.apache.org/recipient-list.html
>>
>> And then you can use a POJO to compute the list of endpoints to send to.
>> The return type of your POJO can for example be String[], or List, or
>> Iterator etc. But to start simple you can use either a List<String> or
>> String[].
>>
>> public List<String> computeSomeEndpoints(File file,
>> @Header("CamelFileName") String name) {
>>      ... compute some endpoints
>>     list.add("jms:queue:foo");
>>     list.add("ftp://someuser@someserver?password=secret");
>>     return list;
>> }
>>
>>
>> And then use a route that route to the recipient list and use the bean
>> as expression
>>
>> from("file://xxxx").recipientList().method(MyComputeBean.class);
>>
>>
>>
>>> I realize that ESB-like products such as Camel may not be a perfect fit
>>> for
>>> this scenario, but Camel has so many of the features I need already built
>>> in...seems like it might be better than writing from scratch.
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Using-Camel-to-%22route%22-binary-files-tp26629157p26629157.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Using-Camel-to-%22route%22-binary-files-tp26629157p26630094.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Using Camel to "route" binary files

Posted by boden <bo...@gmail.com>.
Excellent, thank you very much!

I must say that getting two replies so quickly gives me a lot of confidence
in this project. 


Claus Ibsen-2 wrote:
> 
> On Thu, Dec 3, 2009 at 5:47 PM, boden <bo...@gmail.com> wrote:
>>
>> I need to watch a folder for incoming binary files.  When one appears, I
>> need
>> to examine it to determine where the file is to be sent.  I then need to
>> send the file to one or more "recipients" which may include a network
>> share,
>> email, webdav, and a web service.  It may go to one, multiple, or all of
>> these destinations.  In some cases, where it ends up will also be
>> dynamic,
>> such as the path on a network share (e.g. I know the base share at
>> configuration time, but ultimate path the file is copied to will be
>> dynamic).
>>
>> Is this something that I can do with relative ease in Camel?  If so, can
>> you
>> help get me started?
>>
> 
> Yes it is in fact.
> 
> You want to take a look at the dynamic recipient list EIP
> http://camel.apache.org/recipient-list.html
> 
> And then you can use a POJO to compute the list of endpoints to send to.
> The return type of your POJO can for example be String[], or List, or
> Iterator etc. But to start simple you can use either a List<String> or
> String[].
> 
> public List<String> computeSomeEndpoints(File file,
> @Header("CamelFileName") String name) {
>      ... compute some endpoints
>     list.add("jms:queue:foo");
>     list.add("ftp://someuser@someserver?password=secret");
>     return list;
> }
> 
> 
> And then use a route that route to the recipient list and use the bean
> as expression
> 
> from("file://xxxx").recipientList().method(MyComputeBean.class);
> 
> 
> 
>> I realize that ESB-like products such as Camel may not be a perfect fit
>> for
>> this scenario, but Camel has so many of the features I need already built
>> in...seems like it might be better than writing from scratch.
>> --
>> View this message in context:
>> http://old.nabble.com/Using-Camel-to-%22route%22-binary-files-tp26629157p26629157.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/Using-Camel-to-%22route%22-binary-files-tp26629157p26630094.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using Camel to "route" binary files

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Dec 3, 2009 at 5:47 PM, boden <bo...@gmail.com> wrote:
>
> I need to watch a folder for incoming binary files.  When one appears, I need
> to examine it to determine where the file is to be sent.  I then need to
> send the file to one or more "recipients" which may include a network share,
> email, webdav, and a web service.  It may go to one, multiple, or all of
> these destinations.  In some cases, where it ends up will also be dynamic,
> such as the path on a network share (e.g. I know the base share at
> configuration time, but ultimate path the file is copied to will be
> dynamic).
>
> Is this something that I can do with relative ease in Camel?  If so, can you
> help get me started?
>

Yes it is in fact.

You want to take a look at the dynamic recipient list EIP
http://camel.apache.org/recipient-list.html

And then you can use a POJO to compute the list of endpoints to send to.
The return type of your POJO can for example be String[], or List, or
Iterator etc. But to start simple you can use either a List<String> or
String[].

public List<String> computeSomeEndpoints(File file,
@Header("CamelFileName") String name) {
     ... compute some endpoints
    list.add("jms:queue:foo");
    list.add("ftp://someuser@someserver?password=secret");
    return list;
}


And then use a route that route to the recipient list and use the bean
as expression

from("file://xxxx").recipientList().method(MyComputeBean.class);



> I realize that ESB-like products such as Camel may not be a perfect fit for
> this scenario, but Camel has so many of the features I need already built
> in...seems like it might be better than writing from scratch.
> --
> View this message in context: http://old.nabble.com/Using-Camel-to-%22route%22-binary-files-tp26629157p26629157.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus