You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Craig Taylor <ct...@ctalkobt.net> on 2011/09/02 21:34:26 UTC
Camel 2.2 Removal of Endpoint Files
>From a file based endpoint (eg: file, ftp, sftp) uri I'm attempting to
remove files via the following:
public void removeFilesFromUri( ConsumerTemplate consumerTempl, CamelContext
camlContext, String uri )
{
uri = uri + "&delete=true";
consumerTempl.start();
Exchange exc = consumerTempl.receive(uri,10000);
while( exc != null )
{
System.err.println( "Deleting:" +
exc.getIn().getHeader(Exchange.FILE_NAME) );
// Receive and toss...
exc = consumerTempl.receive(uri,10000);
}
consumerTempl.stop();
camlContext.removeEndpoints(uri);
}
The files are not deleted. I am able to see the "Deleting: " println
entries for the affected endpoint files. I had expected that the act of
receiving an exchange would generate the deletion of them.
Is there anything I need to do to indicate to camel that I'm finished with
the exchange and it's safe for it to remove the file? In other posts I've
seen references to :
exc.getUnitOfWork().done(exc) however, in the code above getUnitOfWork()
returns null.
This is in Camel 2.2 btw (I know... I know... )
Thanks,
--
-------------------------------------------
Craig Taylor
ctalkobt@ctalkobt.net
Re: Camel 2.2 Removal of Endpoint Files
Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Sep 3, 2011 at 7:57 AM, Craig Taylor <ct...@ctalkobt.net> wrote:
> I resolved this issue by dynamically creating a RouteBuilder, then removing
> the route after a small period of time had passed (in my case, it should be
> safe to do).
>
> However, one of the other thoughts that had occurred to me afterwards is
> that camel may be maintaining a list of exchanges internally that have yet
> to be considered "complete". If I had used a producer template to send the
> returned exchange to, a eg: "log:blah" would the delete processing of the
> file endpoint have occurred?
>
Its the file/ftp consumer which executes the delete when the routing is done.
So it doesn't matter how long the route is, if there is one, two, ...
ten EIPs in the route.
Camel has an in-flight registry which keeps track of number of current
in-flight exchanges.
You can take a look into that.
>
> On Fri, Sep 2, 2011 at 3:34 PM, Craig Taylor <ct...@ctalkobt.net> wrote:
>
>> From a file based endpoint (eg: file, ftp, sftp) uri I'm attempting to
>> remove files via the following:
>>
>> public void removeFilesFromUri( ConsumerTemplate consumerTempl,
>> CamelContext camlContext, String uri )
>> {
>> uri = uri + "&delete=true";
>>
>> consumerTempl.start();
>>
>> Exchange exc = consumerTempl.receive(uri,10000);
>> while( exc != null )
>> {
>> System.err.println( "Deleting:" +
>> exc.getIn().getHeader(Exchange.FILE_NAME) );
>>
>> // Receive and toss...
>> exc = consumerTempl.receive(uri,10000);
>> }
>> consumerTempl.stop();
>> camlContext.removeEndpoints(uri);
>> }
>>
>> The files are not deleted. I am able to see the "Deleting: " println
>> entries for the affected endpoint files. I had expected that the act of
>> receiving an exchange would generate the deletion of them.
>>
>> Is there anything I need to do to indicate to camel that I'm finished with
>> the exchange and it's safe for it to remove the file? In other posts I've
>> seen references to :
>> exc.getUnitOfWork().done(exc) however, in the code above getUnitOfWork()
>> returns null.
>>
>> This is in Camel 2.2 btw (I know... I know... )
>>
>> Thanks,
>>
>> --
>> -------------------------------------------
>> Craig Taylor
>> ctalkobt@ctalkobt.net
>>
>>
>
>
> --
> -------------------------------------------
> Craig Taylor
> ctalkobt@ctalkobt.net
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Camel 2.2 Removal of Endpoint Files
Posted by Craig Taylor <ct...@ctalkobt.net>.
I resolved this issue by dynamically creating a RouteBuilder, then removing
the route after a small period of time had passed (in my case, it should be
safe to do).
However, one of the other thoughts that had occurred to me afterwards is
that camel may be maintaining a list of exchanges internally that have yet
to be considered "complete". If I had used a producer template to send the
returned exchange to, a eg: "log:blah" would the delete processing of the
file endpoint have occurred?
On Fri, Sep 2, 2011 at 3:34 PM, Craig Taylor <ct...@ctalkobt.net> wrote:
> From a file based endpoint (eg: file, ftp, sftp) uri I'm attempting to
> remove files via the following:
>
> public void removeFilesFromUri( ConsumerTemplate consumerTempl,
> CamelContext camlContext, String uri )
> {
> uri = uri + "&delete=true";
>
> consumerTempl.start();
>
> Exchange exc = consumerTempl.receive(uri,10000);
> while( exc != null )
> {
> System.err.println( "Deleting:" +
> exc.getIn().getHeader(Exchange.FILE_NAME) );
>
> // Receive and toss...
> exc = consumerTempl.receive(uri,10000);
> }
> consumerTempl.stop();
> camlContext.removeEndpoints(uri);
> }
>
> The files are not deleted. I am able to see the "Deleting: " println
> entries for the affected endpoint files. I had expected that the act of
> receiving an exchange would generate the deletion of them.
>
> Is there anything I need to do to indicate to camel that I'm finished with
> the exchange and it's safe for it to remove the file? In other posts I've
> seen references to :
> exc.getUnitOfWork().done(exc) however, in the code above getUnitOfWork()
> returns null.
>
> This is in Camel 2.2 btw (I know... I know... )
>
> Thanks,
>
> --
> -------------------------------------------
> Craig Taylor
> ctalkobt@ctalkobt.net
>
>
--
-------------------------------------------
Craig Taylor
ctalkobt@ctalkobt.net
Re: Camel 2.2 Removal of Endpoint Files
Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Sep 2, 2011 at 9:34 PM, Craig Taylor <ct...@ctalkobt.net> wrote:
> From a file based endpoint (eg: file, ftp, sftp) uri I'm attempting to
> remove files via the following:
>
> public void removeFilesFromUri( ConsumerTemplate consumerTempl, CamelContext
> camlContext, String uri )
> {
> uri = uri + "&delete=true";
>
> consumerTempl.start();
>
> Exchange exc = consumerTempl.receive(uri,10000);
> while( exc != null )
> {
> System.err.println( "Deleting:" +
> exc.getIn().getHeader(Exchange.FILE_NAME) );
>
> // Receive and toss...
> exc = consumerTempl.receive(uri,10000);
> }
> consumerTempl.stop();
> camlContext.removeEndpoints(uri);
> }
>
> The files are not deleted. I am able to see the "Deleting: " println
> entries for the affected endpoint files. I had expected that the act of
> receiving an exchange would generate the deletion of them.
>
> Is there anything I need to do to indicate to camel that I'm finished with
> the exchange and it's safe for it to remove the file? In other posts I've
> seen references to :
> exc.getUnitOfWork().done(exc) however, in the code above getUnitOfWork()
> returns null.
>
You would need Camel 2.7 or something like (cant remember the exact version)
that to have this working with consumer templates.
There is an API on ConsumerTemplate to execute the done on the exchange.
> This is in Camel 2.2 btw (I know... I know... )
>
> Thanks,
>
> --
> -------------------------------------------
> Craig Taylor
> ctalkobt@ctalkobt.net
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/