You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Justin Rosenberg <Ju...@crlcorp.com> on 2015/05/22 19:38:30 UTC

Synchronous one time use of endpoint

  I would like to leverage the endpoint abstraction Camel provides, but I don't necessarily need a route.  My use case is to simply read a file from an FTP server.  Is there a way to leverage Camel either through the API or a route to synchronously leverage a Camel consumer endpoint?

For example, I would like to do something like this:

  Message message = from("sftp://user@someserver.com/dir/file.txt");

I understand that I could do something like:

  from("sftp://user@someserver.com/dir/file.txt").to(someBean);

However, that would be asynchronous, and potentially consume more than one file.  I could, in theory, spin up a dynamic route, collect messages, and then spin it down, but that would require a lot of management.

Another way to ask the question would be, can I leverage Camel's URI abstraction of the JSCH API without actually creating routes?
~Justin


CONFIDENTIALITY NOTICE:
The information in this message, and any attachment, is intended for the 
sole use of the individual and entity to whom it is addressed. This 
information may be privileged, confidential, and protected from 
disclosure. If you are not the intended recipient you are hereby notified 
that you have received this communication in error and that any review, 
disclosure, dissemination, distribution or copying of it, or its contents, 
is strictly prohibited. If you think that you have received this message 
in error please notify the sender and destroy all copies of this 
communication and any attachments. Thank you.

RE: Synchronous one time use of endpoint

Posted by Justin Rosenberg <Ju...@crlcorp.com>.
Claus,

I know how to filter.  My question is more related on how I set up the route or use the API for a one-time dynamically generated route.  Henryk Konsek recommended I check out the ConsumerTemplate API.  This might be what I'm looking for.

~Justin

-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Tuesday, May 26, 2015 1:31 AM
To: users@camel.apache.org
Subject: Re: Synchronous one time use of endpoint

Hi

To pickup only one file then use the fileName or filter options to select which file.

On Fri, May 22, 2015 at 7:38 PM, Justin Rosenberg <Ju...@crlcorp.com> wrote:
>   I would like to leverage the endpoint abstraction Camel provides, but I don't necessarily need a route.  My use case is to simply read a file from an FTP server.  Is there a way to leverage Camel either through the API or a route to synchronously leverage a Camel consumer endpoint?
>
> For example, I would like to do something like this:
>
>   Message message = from("sftp://user@someserver.com/dir/file.txt");
>
> I understand that I could do something like:
>
>   from("sftp://user@someserver.com/dir/file.txt").to(someBean);
>
> However, that would be asynchronous, and potentially consume more than one file.  I could, in theory, spin up a dynamic route, collect messages, and then spin it down, but that would require a lot of management.
>
> Another way to ask the question would be, can I leverage Camel's URI abstraction of the JSCH API without actually creating routes?
> ~Justin
>
>
> CONFIDENTIALITY NOTICE:
>
> The information in this message, and any attachment, is intended for 
> the
>
> sole use of the individual and entity to whom it is addressed. This
>
> information may be privileged, confidential, and protected from
>
> disclosure. If you are not the intended recipient you are hereby 
> notified
>
> that you have received this communication in error and that any 
> review,
>
> disclosure, dissemination, distribution or copying of it, or its 
> contents,
>
> is strictly prohibited. If you think that you have received this 
> message
>
> in error please notify the sender and destroy all copies of this
>
> communication and any attachments. Thank you.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

CONFIDENTIALITY NOTICE:
The information in this message, and any attachment, is intended for the 
sole use of the individual and entity to whom it is addressed. This 
information may be privileged, confidential, and protected from 
disclosure. If you are not the intended recipient you are hereby notified 
that you have received this communication in error and that any review, 
disclosure, dissemination, distribution or copying of it, or its contents, 
is strictly prohibited. If you think that you have received this message 
in error please notify the sender and destroy all copies of this 
communication and any attachments. Thank you.

Re: Synchronous one time use of endpoint

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

To pickup only one file then use the fileName or filter options to
select which file.

On Fri, May 22, 2015 at 7:38 PM, Justin Rosenberg
<Ju...@crlcorp.com> wrote:
>   I would like to leverage the endpoint abstraction Camel provides, but I don't necessarily need a route.  My use case is to simply read a file from an FTP server.  Is there a way to leverage Camel either through the API or a route to synchronously leverage a Camel consumer endpoint?
>
> For example, I would like to do something like this:
>
>   Message message = from("sftp://user@someserver.com/dir/file.txt");
>
> I understand that I could do something like:
>
>   from("sftp://user@someserver.com/dir/file.txt").to(someBean);
>
> However, that would be asynchronous, and potentially consume more than one file.  I could, in theory, spin up a dynamic route, collect messages, and then spin it down, but that would require a lot of management.
>
> Another way to ask the question would be, can I leverage Camel's URI abstraction of the JSCH API without actually creating routes?
> ~Justin
>
>
> CONFIDENTIALITY NOTICE:
>
> The information in this message, and any attachment, is intended for the
>
> sole use of the individual and entity to whom it is addressed. This
>
> information may be privileged, confidential, and protected from
>
> disclosure. If you are not the intended recipient you are hereby notified
>
> that you have received this communication in error and that any review,
>
> disclosure, dissemination, distribution or copying of it, or its contents,
>
> is strictly prohibited. If you think that you have received this message
>
> in error please notify the sender and destroy all copies of this
>
> communication and any attachments. Thank you.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

RE: Synchronous one time use of endpoint

Posted by Justin Rosenberg <Ju...@crlcorp.com>.
Thank you Henryk.  That's what I was looking for.  To wrap this up for others looking to do the same:

ConsumerTemplate consumerTemplate = camelContext.createConsumerTemplate();

Exchange exchange = consumerTemplate.receive(fileURI, timeout);
try {
  consumerTemplate.stop();
} catch (Exception e) {
  //Handle not being able to stop context otherwise the consumer will continue to poll.
}

if (exchange != null) {
  byte[] fileBytes = exchange.getIn().getBody(byte[].class);
}

~Justin


-----Original Message-----
From: Henryk Konsek [mailto:hekonsek@gmail.com] 
Sent: Saturday, May 23, 2015 1:18 PM
To: users@camel.apache.org
Subject: Re: Synchronous one time use of endpoint

Hi Justin,

Have you tried to use ConsumerTemplate API? It allows you to dynamically create an endpoint and consume a single message from it.

Cheers!

pt., 22.05.2015 o 19:38 użytkownik Justin Rosenberg < Justin.Rosenberg@crlcorp.com> napisał:

>   I would like to leverage the endpoint abstraction Camel provides, 
> but I don't necessarily need a route.  My use case is to simply read a 
> file from an FTP server.  Is there a way to leverage Camel either 
> through the API or a route to synchronously leverage a Camel consumer endpoint?
>
> For example, I would like to do something like this:
>
>   Message message = from("sftp://user@someserver.com/dir/file.txt");
>
> I understand that I could do something like:
>
>   from("sftp://user@someserver.com/dir/file.txt").to(someBean);
>
> However, that would be asynchronous, and potentially consume more than 
> one file.  I could, in theory, spin up a dynamic route, collect 
> messages, and then spin it down, but that would require a lot of management.
>
> Another way to ask the question would be, can I leverage Camel's URI 
> abstraction of the JSCH API without actually creating routes?
> ~Justin
>
>
> CONFIDENTIALITY NOTICE:
> The information in this message, and any attachment, is intended for 
> the sole use of the individual and entity to whom it is addressed. 
> This information may be privileged, confidential, and protected from 
> disclosure. If you are not the intended recipient you are hereby 
> notified that you have received this communication in error and that 
> any review, disclosure, dissemination, distribution or copying of it, 
> or its contents, is strictly prohibited. If you think that you have 
> received this message in error please notify the sender and destroy 
> all copies of this communication and any attachments. Thank you.
>

CONFIDENTIALITY NOTICE:
The information in this message, and any attachment, is intended for the 
sole use of the individual and entity to whom it is addressed. This 
information may be privileged, confidential, and protected from 
disclosure. If you are not the intended recipient you are hereby notified 
that you have received this communication in error and that any review, 
disclosure, dissemination, distribution or copying of it, or its contents, 
is strictly prohibited. If you think that you have received this message 
in error please notify the sender and destroy all copies of this 
communication and any attachments. Thank you.

Re: Synchronous one time use of endpoint

Posted by Henryk Konsek <he...@gmail.com>.
Hi Justin,

Have you tried to use ConsumerTemplate API? It allows you to dynamically
create an endpoint and consume a single message from it.

Cheers!

pt., 22.05.2015 o 19:38 użytkownik Justin Rosenberg <
Justin.Rosenberg@crlcorp.com> napisał:

>   I would like to leverage the endpoint abstraction Camel provides, but I
> don't necessarily need a route.  My use case is to simply read a file from
> an FTP server.  Is there a way to leverage Camel either through the API or
> a route to synchronously leverage a Camel consumer endpoint?
>
> For example, I would like to do something like this:
>
>   Message message = from("sftp://user@someserver.com/dir/file.txt");
>
> I understand that I could do something like:
>
>   from("sftp://user@someserver.com/dir/file.txt").to(someBean);
>
> However, that would be asynchronous, and potentially consume more than one
> file.  I could, in theory, spin up a dynamic route, collect messages, and
> then spin it down, but that would require a lot of management.
>
> Another way to ask the question would be, can I leverage Camel's URI
> abstraction of the JSCH API without actually creating routes?
> ~Justin
>
>
> CONFIDENTIALITY NOTICE:
> The information in this message, and any attachment, is intended for the
> sole use of the individual and entity to whom it is addressed. This
> information may be privileged, confidential, and protected from
> disclosure. If you are not the intended recipient you are hereby notified
> that you have received this communication in error and that any review,
> disclosure, dissemination, distribution or copying of it, or its contents,
> is strictly prohibited. If you think that you have received this message
> in error please notify the sender and destroy all copies of this
> communication and any attachments. Thank you.
>