The way I proposed does not take much effort, especially if you are using
groovy (a little more if you are using Java).  The solution is deep enough
into the api that some maintenance might be required to make sure it works
with ongoing camel upgrades.  If you really dont want to go deeper than
RouteBuilder.configure() I would use the suggestions above.  Mine has the
benefit of working with camel's entire file library (file, sftp, ftp, etc),
and if need be any other scheduled polling consumers that should only run
once.

If you are just using files mine is probably overkill, just use a bean or
pollenrich.  I originally wrote this code to deal with sftp, but I use it
for file as well.

If you want the code I am happy to find it at some point.

On Mon, Jul 2, 2012 at 10:28 AM, thomas barker <[email protected]>wrote:

> I have done this before, it may take me a bit to find the code.  I think
> you accomplish it by doing the following:
>
> 1.  Override the from(String) method in RouteBuilder
> 2.  Use getContext().getEndpoint(uri) to get the endpoint, if the endpoint
> is not a scheduledpollingendpoint then do super.from(uri) otherwise continue
> 3.  create a wrapping endpoint and wrapping consumer to wrap a scheduled
> endpoint and a scheduled polling consumer
>
>    - for the doStart method of the wrapping consumer call
>    wrappedConsumer.run(), this will do only one poll and the doStart will not
>    end till the poll is done
>
> 4.  return super.from(wrappedEndpoint) in the overridden method
>
> If I remember right, I think there are some issues if the wrapped consumer
> is a RemoteFileConsumer, but this works pretty well.  I will try to put
> this together in a groovy class soon to help you out.
>
>
> On Mon, Jul 2, 2012 at 10:17 AM, raphael <[email protected]>wrote:
>
>> OK, it's working by transforming the body in File(filename).
>>
>> But in that scenario, I lost all the features of the file component,
>> right ?
>> (like move option for example).
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/File-consumer-event-based-not-polling-tp5715349p5715355.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>

Reply via email to