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:hekon...@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.rosenb...@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://u...@someserver.com/dir/file.txt";);
>
> I understand that I could do something like:
>
>   from("sftp://u...@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.

Reply via email to