You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by bocamel <jo...@gmail.com> on 2013/05/03 04:51:06 UTC

Camel retries a message after the message has been completed successfully

Hello, I was testing a Camel CXF web services application.  I ran into this
problem.

In my Camel web services test application, I have two routes:

First route reads messages from a folder (src/data/in), sends the messages
to my web services, and then writes the response to another folder
(src/data/out).  This route is added to the app just for testing the web
services server.

Second route represents the web services server.  It receives the web
services calls and processes the requests.

My test client simply adds messages as files into src/data/in, in a loop. 
Once in a while Camel would throw the following exception:
*org.apache.camel.InvalidPayloadException* because it could not find a
specific file in src/data/in.  But always, the file that Camel could not
find had already been successfully processed by Camel.  It puzzles me why
Camel attempts to redeliver a message when it has delivered successfully
already.  It seems to have something to do with concurrency.  It only
happens when the test client adds a lot of files (several hundreds) to
src/data/in and Camel processes the messages concurrently.

Here are the two routes in Spring (simplified to reproduce the problem). 
The CXF endpoints in the two routes are really the same endpoint.  One used
by the web services test client, one used by the server.

Route 1 (for test client): 

	<camel:route id="clientRoute" handleFault="true">
		<camel:from uri="file:src/data/in" />
		<camel:to uri="cxf:bean:ttEndpoint2" />
		<camel:to uri="file:src/data/out" />			
		<camel:log message="Web Services call for ${headers.CamelFileName}
completed." />
	</camel:route>

Route 2 (for web services server):

	<camel:route id="serverRoute">
		<camel:from uri="cxf:bean:ttEndpoint" />
		<camel:setHeader headerName="echoString">
			<camel:xpath resultType="java.lang.String">/ns:SayHello/in</camel:xpath>
		</camel:setHeader>
		<camel:to uri="velocity:helloWorldResponse.vm" />
	</camel:route>

Any help will be greatly appreciated.  Here is the error message from
console:

[          default-workqueue-12] clientRoute                    INFO  Web
Services call for test20130502-221000754.xml completed.
[           default-workqueue-1] clientRoute                    INFO  Web
Services call for test20130502-221001478.xml completed.
[          default-workqueue-20] clientRoute                    INFO  Web
Services call for test20130502-221001519.xml completed.
[          default-workqueue-10] clientRoute                    INFO  Web
Services call for *test20130502-221001559.xml* completed.
[          default-workqueue-11] clientRoute                    INFO  Web
Services call for test20130502-221001425.xml completed.
[           default-workqueue-7] clientRoute                    INFO  Web
Services call for test20130502-221001003.xml completed.
[          default-workqueue-22] clientRoute                    INFO  Web
Services call for test20130502-221000915.xml completed.
[           default-workqueue-3] clientRoute                    INFO  Web
Services call for test20130502-221001312.xml completed.
[           default-workqueue-5] clientRoute                    INFO  Web
Services call for test20130502-221001180.xml completed.
[thread #0 - file://src/data/in] DefaultErrorHandler            ERROR Failed
delivery for (MessageId: ID-John-PCI-50932-1367546949875-0-4910 on
ExchangeId: ID-John-PCI-50932-1367546949875-0-4911). Exhausted after
delivery attempt: 1 caught: org.apache.camel.InvalidPayloadException: No
body available of type: org.apache.camel.component.cxf.CxfPayload but has
value: GenericFile[test20130502-221001559.xml] of type:
org.apache.camel.component.file.GenericFile on: test20130502-221001559.xml.
Caused by: Error during type conversion from type:
org.apache.camel.component.file.GenericFile to the required type: byte[]
with value GenericFile[test20130502-221001559.xml] due
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
(The system cannot find the file specified).
Exchange[test20130502-221001559.xml]. Caused by:
[org.apache.camel.TypeConversionException - Error during type conversion
from type: org.apache.camel.component.file.GenericFile to the required type:
byte[] with value GenericFile[test20130502-221001559.xml] due
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\*test20130502-221001559.xml
*(The system cannot find the file specified)]
org.apache.camel.InvalidPayloadException: No body available of type:
org.apache.camel.component.cxf.CxfPayload but has value:
GenericFile[test20130502-221001559.xml] of type:
org.apache.camel.component.file.GenericFile on: test20130502-221001559.xml.
Caused by: Error during type conversion from type:
org.apache.camel.component.file.GenericFile to the required type: byte[]
with value GenericFile[test20130502-221001559.xml] due
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
(The system cannot find the file specified).
Exchange[test20130502-221001559.xml]. Caused by:
[org.apache.camel.TypeConversionException - Error during type conversion
from type: org.apache.camel.component.file.GenericFile to the required type:
byte[] with value GenericFile[test20130502-221001559.xml] due
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
(The system cannot find the file specified)]
	at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)
	at
org.apache.camel.component.cxf.CxfProducer.getParams(CxfProducer.java:305)
	at org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:112)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:122)
	at
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:298)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.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.processor.interceptor.BacklogTracerInterceptor.process(BacklogTracerInterceptor.java:84)
	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.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
	at
org.apache.camel.processor.interceptor.HandleFaultInterceptor.process(HandleFaultInterceptor.java:41)
	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.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:390)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:273)
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:335)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
	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.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	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:72)
	at
org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:350)
	at
org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:197)
	at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:163)
	at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:141)
	at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:91)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.camel.TypeConversionException: Error during type
conversion from type: org.apache.camel.component.file.GenericFile to the
required type: byte[] with value GenericFile[test20130502-221001559.xml] due
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
(The system cannot find the file specified)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:173)
	at
org.apache.camel.component.file.FileBinding.loadContent(FileBinding.java:57)
	at
org.apache.camel.component.file.GenericFileConverter.genericFileToInputStream(GenericFileConverter.java:123)
	at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:980)
	at
org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:47)
	at
org.apache.camel.component.cxf.converter.CxfPayloadConverter.convertVia(CxfPayloadConverter.java:249)
	at
org.apache.camel.component.cxf.converter.CxfPayloadConverter.convertTo(CxfPayloadConverter.java:157)
	at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:980)
	at
org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:50)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:311)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:164)
	at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)
	... 50 more
Caused by: org.apache.camel.RuntimeCamelException:
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
(The system cannot find the file specified)
	at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1338)
	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:984)
	at
org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:47)
	at
org.apache.camel.component.file.GenericFileConverter.convertTo(GenericFileConverter.java:97)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:980)
	at
org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:50)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:311)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:164)
	... 67 more
Caused by: java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
(The system cannot find the file specified)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at
org.apache.camel.converter.IOConverter.toInputStream(IOConverter.java:73)
	at org.apache.camel.converter.IOConverter.toByteArray(IOConverter.java:248)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:980)
	... 77 more
[thread #0 - file://src/data/in] GenericFileOnCompletion        WARN 
Rollback file strategy:
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@49cad364
for file: GenericFile[test20130502-221001559.xml]
[           default-workqueue-6] clientRoute                    INFO  Web
Services call for test20130502-221001598.xml completed.
[          default-workqueue-24] clientRoute                    INFO  Web
Services call for test20130502-221001717.xml completed.
[           default-workqueue-4] clientRoute                    INFO  Web
Services call for test20130502-221001657.xml completed.
[          default-workqueue-13] clientRoute                    INFO  Web
Services call for test20130502-221001889.xml completed.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-retries-a-message-after-the-message-has-been-completed-successfully-tp5731930.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel retries a message after the message has been completed successfully

Posted by bocamel <jo...@gmail.com>.
I can avoid this issue by throttling the file polling by adding the following
options to the file uri:

initialDelay=3000&delay=1000&maxMessagesPerPoll=20. 

It seems that the exception occurs in one of the following two situations:

1. When Camel polls the folder immediately after being started while there
are many files in the folder.  The increase of initialDelay seems to help.  

2. When Camel polls more new files while previously polled files have not
been processed completely.

If anyone can shed some light on this, that would greatly appreciated.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-retries-a-message-after-the-message-has-been-completed-successfully-tp5731930p5732044.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel retries a message after the message has been completed successfully

Posted by bocamel <jo...@gmail.com>.
Claus,

Thank you very much for your prompt response.  I tried to load the messages
in memory as you suggested.  But the same exception (system cannot find the
file, see below) still occurs.  Could you please share what you think might
be the cause for this?  It seems that the locking mechanism of the File
component might not be airtight.

[thread #0 - file://src/data/in] DefaultErrorHandler            ERROR Failed
delivery for (MessageId: ID-John-PCI-51304-1367586446106-0-6201 on
ExchangeId: ID-John-PCI-51304-1367586446106-0-6202). Exhausted after
delivery attempt: 1 caught: org.apache.camel.InvalidPayloadException: No
body available of type: java.lang.String but has value:
GenericFile[test20130503-090823021.xml] of type:
org.apache.camel.component.file.GenericFile on: test20130503-090823021.xml.
Caused by: Error during type conversion from type:
org.apache.camel.component.file.GenericFile to the required type: byte[]
with value GenericFile[test20130503-090823021.xml] due
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130503-090823021.xml
(The system cannot find the file specified).
Exchange[test20130503-090823021.xml]. Caused by:
[org.apache.camel.TypeConversionException - Error during type conversion
from type: org.apache.camel.component.file.GenericFile to the required type:
byte[] with value GenericFile[test20130503-090823021.xml] due
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130503-090823021.xml
(The system cannot find the file specified)]
org.apache.camel.InvalidPayloadException: No body available of type:
java.lang.String but has value: GenericFile[test20130503-090823021.xml] of
type: org.apache.camel.component.file.GenericFile on:
test20130503-090823021.xml. Caused by: Error during type conversion from
type: org.apache.camel.component.file.GenericFile to the required type:
byte[] with value GenericFile[test20130503-090823021.xml] due
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130503-090823021.xml
(The system cannot find the file specified).
Exchange[test20130503-090823021.xml]. Caused by:
[org.apache.camel.TypeConversionException - Error during type conversion
from type: org.apache.camel.component.file.GenericFile to the required type:
byte[] with value GenericFile[test20130503-090823021.xml] due
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130503-090823021.xml
(The system cannot find the file specified)]
	at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)
	at
org.apache.camel.processor.ConvertBodyProcessor.process(ConvertBodyProcessor.java:68)
	at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
	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.processor.interceptor.BacklogTracerInterceptor.process(BacklogTracerInterceptor.java:84)
	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.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
	at
org.apache.camel.processor.interceptor.HandleFaultInterceptor.process(HandleFaultInterceptor.java:41)
	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.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:390)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:273)
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:335)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
	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.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	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:72)
	at
org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:350)
	at
org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:197)
	at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:163)
	at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:141)
	at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:91)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.camel.TypeConversionException: Error during type
conversion from type: org.apache.camel.component.file.GenericFile to the
required type: byte[] with value GenericFile[test20130503-090823021.xml] due
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130503-090823021.xml
(The system cannot find the file specified)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:173)
	at
org.apache.camel.component.file.FileBinding.loadContent(FileBinding.java:57)
	at
org.apache.camel.component.file.GenericFileConverter.genericFileToString(GenericFileConverter.java:140)
	at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:980)
	at
org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:47)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:275)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:164)
	at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)
	... 46 more
Caused by: org.apache.camel.RuntimeCamelException:
java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130503-090823021.xml
(The system cannot find the file specified)
	at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1338)
	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:984)
	at
org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:47)
	at
org.apache.camel.component.file.GenericFileConverter.convertTo(GenericFileConverter.java:97)
	at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:980)
	at
org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:50)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:311)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:164)
	... 56 more
Caused by: java.io.FileNotFoundException:
C:\Users\John\workspace\TestConcurrency\src\data\in\test20130503-090823021.xml
(The system cannot find the file specified)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at
org.apache.camel.converter.IOConverter.toInputStream(IOConverter.java:73)
	at org.apache.camel.converter.IOConverter.toByteArray(IOConverter.java:248)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:980)
	... 65 more
[thread #0 - file://src/data/in] GenericFileOnCompletion        WARN 
Rollback file strategy:
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@597e648b
for file: GenericFile[test20130503-090823021.xml]




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-retries-a-message-after-the-message-has-been-completed-successfully-tp5731930p5731971.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel retries a message after the message has been completed successfully

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

You can load the content of the file into memory before calling CXF.


  <camel:from uri="file:src/data/in" />
  <camel:convertBodyTo type="String"/>
                <camel:to uri="cxf:bean:ttEndpoint2" />


On Fri, May 3, 2013 at 4:51 AM, bocamel <jo...@gmail.com> wrote:
> Hello, I was testing a Camel CXF web services application.  I ran into this
> problem.
>
> In my Camel web services test application, I have two routes:
>
> First route reads messages from a folder (src/data/in), sends the messages
> to my web services, and then writes the response to another folder
> (src/data/out).  This route is added to the app just for testing the web
> services server.
>
> Second route represents the web services server.  It receives the web
> services calls and processes the requests.
>
> My test client simply adds messages as files into src/data/in, in a loop.
> Once in a while Camel would throw the following exception:
> *org.apache.camel.InvalidPayloadException* because it could not find a
> specific file in src/data/in.  But always, the file that Camel could not
> find had already been successfully processed by Camel.  It puzzles me why
> Camel attempts to redeliver a message when it has delivered successfully
> already.  It seems to have something to do with concurrency.  It only
> happens when the test client adds a lot of files (several hundreds) to
> src/data/in and Camel processes the messages concurrently.
>
> Here are the two routes in Spring (simplified to reproduce the problem).
> The CXF endpoints in the two routes are really the same endpoint.  One used
> by the web services test client, one used by the server.
>
> Route 1 (for test client):
>
>         <camel:route id="clientRoute" handleFault="true">
>                 <camel:from uri="file:src/data/in" />
>                 <camel:to uri="cxf:bean:ttEndpoint2" />
>                 <camel:to uri="file:src/data/out" />
>                 <camel:log message="Web Services call for ${headers.CamelFileName}
> completed." />
>         </camel:route>
>
> Route 2 (for web services server):
>
>         <camel:route id="serverRoute">
>                 <camel:from uri="cxf:bean:ttEndpoint" />
>                 <camel:setHeader headerName="echoString">
>                         <camel:xpath resultType="java.lang.String">/ns:SayHello/in</camel:xpath>
>                 </camel:setHeader>
>                 <camel:to uri="velocity:helloWorldResponse.vm" />
>         </camel:route>
>
> Any help will be greatly appreciated.  Here is the error message from
> console:
>
> [          default-workqueue-12] clientRoute                    INFO  Web
> Services call for test20130502-221000754.xml completed.
> [           default-workqueue-1] clientRoute                    INFO  Web
> Services call for test20130502-221001478.xml completed.
> [          default-workqueue-20] clientRoute                    INFO  Web
> Services call for test20130502-221001519.xml completed.
> [          default-workqueue-10] clientRoute                    INFO  Web
> Services call for *test20130502-221001559.xml* completed.
> [          default-workqueue-11] clientRoute                    INFO  Web
> Services call for test20130502-221001425.xml completed.
> [           default-workqueue-7] clientRoute                    INFO  Web
> Services call for test20130502-221001003.xml completed.
> [          default-workqueue-22] clientRoute                    INFO  Web
> Services call for test20130502-221000915.xml completed.
> [           default-workqueue-3] clientRoute                    INFO  Web
> Services call for test20130502-221001312.xml completed.
> [           default-workqueue-5] clientRoute                    INFO  Web
> Services call for test20130502-221001180.xml completed.
> [thread #0 - file://src/data/in] DefaultErrorHandler            ERROR Failed
> delivery for (MessageId: ID-John-PCI-50932-1367546949875-0-4910 on
> ExchangeId: ID-John-PCI-50932-1367546949875-0-4911). Exhausted after
> delivery attempt: 1 caught: org.apache.camel.InvalidPayloadException: No
> body available of type: org.apache.camel.component.cxf.CxfPayload but has
> value: GenericFile[test20130502-221001559.xml] of type:
> org.apache.camel.component.file.GenericFile on: test20130502-221001559.xml.
> Caused by: Error during type conversion from type:
> org.apache.camel.component.file.GenericFile to the required type: byte[]
> with value GenericFile[test20130502-221001559.xml] due
> java.io.FileNotFoundException:
> C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
> (The system cannot find the file specified).
> Exchange[test20130502-221001559.xml]. Caused by:
> [org.apache.camel.TypeConversionException - Error during type conversion
> from type: org.apache.camel.component.file.GenericFile to the required type:
> byte[] with value GenericFile[test20130502-221001559.xml] due
> java.io.FileNotFoundException:
> C:\Users\John\workspace\TestConcurrency\src\data\in\*test20130502-221001559.xml
> *(The system cannot find the file specified)]
> org.apache.camel.InvalidPayloadException: No body available of type:
> org.apache.camel.component.cxf.CxfPayload but has value:
> GenericFile[test20130502-221001559.xml] of type:
> org.apache.camel.component.file.GenericFile on: test20130502-221001559.xml.
> Caused by: Error during type conversion from type:
> org.apache.camel.component.file.GenericFile to the required type: byte[]
> with value GenericFile[test20130502-221001559.xml] due
> java.io.FileNotFoundException:
> C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
> (The system cannot find the file specified).
> Exchange[test20130502-221001559.xml]. Caused by:
> [org.apache.camel.TypeConversionException - Error during type conversion
> from type: org.apache.camel.component.file.GenericFile to the required type:
> byte[] with value GenericFile[test20130502-221001559.xml] due
> java.io.FileNotFoundException:
> C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
> (The system cannot find the file specified)]
>         at
> org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)
>         at
> org.apache.camel.component.cxf.CxfProducer.getParams(CxfProducer.java:305)
>         at org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:112)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:122)
>         at
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:298)
>         at org.apache.camel.processor.SendProcessor.process(SendProcessor.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.processor.interceptor.BacklogTracerInterceptor.process(BacklogTracerInterceptor.java:84)
>         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.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
>         at
> org.apache.camel.processor.interceptor.HandleFaultInterceptor.process(HandleFaultInterceptor.java:41)
>         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.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:390)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:273)
>         at
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:335)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>         at
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
>         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.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         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:72)
>         at
> org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:350)
>         at
> org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:197)
>         at
> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:163)
>         at
> org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:141)
>         at
> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:91)
>         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>         at
> java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
>         at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
>         at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
>         at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
>         at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
>         at java.lang.Thread.run(Thread.java:722)
> Caused by: org.apache.camel.TypeConversionException: Error during type
> conversion from type: org.apache.camel.component.file.GenericFile to the
> required type: byte[] with value GenericFile[test20130502-221001559.xml] due
> java.io.FileNotFoundException:
> C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
> (The system cannot find the file specified)
>         at
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:173)
>         at
> org.apache.camel.component.file.FileBinding.loadContent(FileBinding.java:57)
>         at
> org.apache.camel.component.file.GenericFileConverter.genericFileToInputStream(GenericFileConverter.java:123)
>         at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:601)
>         at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:980)
>         at
> org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:47)
>         at
> org.apache.camel.component.cxf.converter.CxfPayloadConverter.convertVia(CxfPayloadConverter.java:249)
>         at
> org.apache.camel.component.cxf.converter.CxfPayloadConverter.convertTo(CxfPayloadConverter.java:157)
>         at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:601)
>         at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:980)
>         at
> org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:50)
>         at
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:311)
>         at
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:164)
>         at
> org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)
>         ... 50 more
> Caused by: org.apache.camel.RuntimeCamelException:
> java.io.FileNotFoundException:
> C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
> (The system cannot find the file specified)
>         at
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1338)
>         at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:984)
>         at
> org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:47)
>         at
> org.apache.camel.component.file.GenericFileConverter.convertTo(GenericFileConverter.java:97)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:601)
>         at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:980)
>         at
> org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:50)
>         at
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:311)
>         at
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:164)
>         ... 67 more
> Caused by: java.io.FileNotFoundException:
> C:\Users\John\workspace\TestConcurrency\src\data\in\test20130502-221001559.xml
> (The system cannot find the file specified)
>         at java.io.FileInputStream.open(Native Method)
>         at java.io.FileInputStream.<init>(FileInputStream.java:138)
>         at
> org.apache.camel.converter.IOConverter.toInputStream(IOConverter.java:73)
>         at org.apache.camel.converter.IOConverter.toByteArray(IOConverter.java:248)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:601)
>         at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:980)
>         ... 77 more
> [thread #0 - file://src/data/in] GenericFileOnCompletion        WARN
> Rollback file strategy:
> org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@49cad364
> for file: GenericFile[test20130502-221001559.xml]
> [           default-workqueue-6] clientRoute                    INFO  Web
> Services call for test20130502-221001598.xml completed.
> [          default-workqueue-24] clientRoute                    INFO  Web
> Services call for test20130502-221001717.xml completed.
> [           default-workqueue-4] clientRoute                    INFO  Web
> Services call for test20130502-221001657.xml completed.
> [          default-workqueue-13] clientRoute                    INFO  Web
> Services call for test20130502-221001889.xml completed.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-retries-a-message-after-the-message-has-been-completed-successfully-tp5731930.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen