You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hefiso <he...@gmail.com> on 2012/03/29 13:25:27 UTC

File-component not transacted?

Hi

I have a simple route where I consume a file and write it to a queue:

<route id="foo-route">
	<from ref="file:/some_folder?delete=true&amp;delay=60s" />
	<transacted/>
	<to uri="hubQueue:queue:MY_HUB?jmsMessageType=Text" />	
</route>

When camel tries to delete the file a GenericFileOperationFailedException is
thrown but the message (file) is left on the queue and *not* rolled back as
I would expect due to "<transacted />". Why is this happening and what can I
do to make camel rollback when the file can not be deleted (consumed)?

The full stacktrace looks like this:

org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
delete file: GenericFile[/some_folder/foo.xml]
        at
org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy.commit(GenericFileDeleteProcessStrategy.java:82)
        at
org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:132)
        at
org.apache.camel.component.file.GenericFileOnCompletion.onCompletion(GenericFileOnCompletion.java:83)
        at
org.apache.camel.component.file.GenericFileOnCompletion.onComplete(GenericFileOnCompletion.java:54)
        at
org.apache.camel.util.UnitOfWorkHelper.doneSynchronizations(UnitOfWorkHelper.java:56)
        at
org.apache.camel.impl.DefaultUnitOfWork.done(DefaultUnitOfWork.java:222)
        at
org.apache.camel.processor.UnitOfWorkProcessor.doneUow(UnitOfWorkProcessor.java:199)
        at
org.apache.camel.processor.UnitOfWorkProcessor.access$000(UnitOfWorkProcessor.java:37)
        at
org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:157)
        at
org.apache.camel.processor.RouteContextProcessor$1.done(RouteContextProcessor.java:56)
        at
org.apache.camel.processor.RouteContextProcessor$1.done(RouteContextProcessor.java:56)
        at
org.apache.camel.processor.RouteContextProcessor$1.done(RouteContextProcessor.java:56)
        at
org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:116)
        at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:61)
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
        at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304)
        at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:61)
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
        at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:61)
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
        at
org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
        at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
        at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
        at
org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:352)
        at
org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:175)
        at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:136)
        at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:140)
        at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)


TIA
Henrik

--
View this message in context: http://camel.465427.n5.nabble.com/File-component-not-transacted-tp5603448p5603448.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: File-component not transacted?

Posted by David Karlsen <da...@gmail.com>.
Either that or commons. Transactions from apache. I have a spring
transactionmanager abstraction of that again on github - could be
interesting or not.
Den 29. mars 2012 22:16 skrev "Reuben Garrett" <re...@gmail.com>
følgende:

> yes, i remember filesystem operations in java tending towards the "lowest
> common denominator" (e.g. locks are advisory [1]).
>
> maybe idempotency [2] in flows downstream of the file consumption could
> help achieve the desired behaviour?
>
> [1]:
> http://docs.oracle.com/javase/6/docs/api/java/nio/channels/FileLock.html
> [2]: http://camel.apache.org/idempotent-consumer.html
>
> ~ Reuben
>
> On Thu, Mar 29, 2012 at 14:38, Christian Müller <
> christian.mueller@gmail.com
> > wrote:
>
> > The file protocol per se doesn't support transactions. In Camel we try to
> > mimic the transactional behavior with error compensation if something
> went
> > wrong. But if we hit an error after we committed the JMS messages (which
> > supports transactions), we cannot do anything else.
> >
>

Re: File-component not transacted?

Posted by Reuben Garrett <re...@gmail.com>.
yes, i remember filesystem operations in java tending towards the "lowest
common denominator" (e.g. locks are advisory [1]).

maybe idempotency [2] in flows downstream of the file consumption could
help achieve the desired behaviour?

[1]:
http://docs.oracle.com/javase/6/docs/api/java/nio/channels/FileLock.html
[2]: http://camel.apache.org/idempotent-consumer.html

~ Reuben

On Thu, Mar 29, 2012 at 14:38, Christian Müller <christian.mueller@gmail.com
> wrote:

> The file protocol per se doesn't support transactions. In Camel we try to
> mimic the transactional behavior with error compensation if something went
> wrong. But if we hit an error after we committed the JMS messages (which
> supports transactions), we cannot do anything else.
>

Re: File-component not transacted?

Posted by Christian Müller <ch...@gmail.com>.
The file protocol per se doesn't support transactions. In Camel we try to
mimic the transactional behavior with error compensation if something went
wrong. But if we hit an error after we committed the JMS messages (which
supports transactions), we cannot do anything else.

Best,
Christian

On Thu, Mar 29, 2012 at 1:25 PM, hefiso <
henrik.filtenborg.sorensen@gmail.com> wrote:

> Hi
>
> I have a simple route where I consume a file and write it to a queue:
>
> <route id="foo-route">
>        <from ref="file:/some_folder?delete=true&amp;delay=60s" />
>        <transacted/>
>        <to uri="hubQueue:queue:MY_HUB?jmsMessageType=Text" />
> </route>
>
> When camel tries to delete the file a GenericFileOperationFailedException
> is
> thrown but the message (file) is left on the queue and *not* rolled back as
> I would expect due to "<transacted />". Why is this happening and what can
> I
> do to make camel rollback when the file can not be deleted (consumed)?
>
> The full stacktrace looks like this:
>
> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
> delete file: GenericFile[/some_folder/foo.xml]
>        at
>
> org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy.commit(GenericFileDeleteProcessStrategy.java:82)
>        at
>
> org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:132)
>        at
>
> org.apache.camel.component.file.GenericFileOnCompletion.onCompletion(GenericFileOnCompletion.java:83)
>        at
>
> org.apache.camel.component.file.GenericFileOnCompletion.onComplete(GenericFileOnCompletion.java:54)
>        at
>
> org.apache.camel.util.UnitOfWorkHelper.doneSynchronizations(UnitOfWorkHelper.java:56)
>        at
> org.apache.camel.impl.DefaultUnitOfWork.done(DefaultUnitOfWork.java:222)
>        at
>
> org.apache.camel.processor.UnitOfWorkProcessor.doneUow(UnitOfWorkProcessor.java:199)
>        at
>
> org.apache.camel.processor.UnitOfWorkProcessor.access$000(UnitOfWorkProcessor.java:37)
>        at
>
> org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:157)
>        at
>
> org.apache.camel.processor.RouteContextProcessor$1.done(RouteContextProcessor.java:56)
>        at
>
> org.apache.camel.processor.RouteContextProcessor$1.done(RouteContextProcessor.java:56)
>        at
>
> org.apache.camel.processor.RouteContextProcessor$1.done(RouteContextProcessor.java:56)
>        at
>
> org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:116)
>        at
>
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:61)
>        at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>        at
>
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304)
>        at
>
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:61)
>        at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>        at
>
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:61)
>        at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>        at
>
> org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
>        at
>
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
>        at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>        at
>
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>        at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>        at
>
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>        at
>
> org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:352)
>        at
>
> org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:175)
>        at
>
> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:136)
>        at
>
> org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:140)
>        at
>
> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
>        at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
>        at
>
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
>        at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>        at java.lang.Thread.run(Thread.java:662)
>
>
> TIA
> Henrik
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/File-component-not-transacted-tp5603448p5603448.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>