Hi

I'm trying to do a use case similar to the one on page 371 in Camel in
Action.
I need to start a route. Copy a batch of files from FTP, and then shut it
down again.

Pseudo Spring DSL:

<from uri="ftp:data/in">
  <onCompletion>
  <filter>
  <simple>${property.CamelBatchComplete} == true</simple>
  <to uri="StopThisRouteProcessor">
  </filter
</onCompletion>
<to uri="file:data/out">

I check if the property set by BatchConsumers - CamelBatchComplete is true,
and if it is the last Exchange of the batch I shut down the route.

This doesn't work correctly, I get a SocketException because the route is
shut down before it is done processing the files.

On top of this it seems to only fail when there's only one file on the ftp
directory.

I expected that onCompletion first would be triggered when the entire route
is completely done processing but it doesn't seem to be the case - is this a
bug or am I doing it wrong?

Debug output:

2010-05-28 16:36:21,274 INFO  [Camel Thread 0 -
ftp://localhost/inbox?move=done&password=camel123&username=camel]
[FtpPollingRoute]: Fetching  camel-core-2.2.0-fuse-01-00.jar
2010-05-28 16:36:21,290 INFO  [Camel Thread 0 -
ftp://localhost/inbox?move=done&password=camel123&username=camel]
[FtpPollingRoute]: camel-core-2.2.0-fuse-01-00.jar copied
2010-05-28 16:36:21,290 INFO  [Camel Thread 1 - OnCompletion]
[FtpPollingRoute]: onComplete =  false
2010-05-28 16:36:27,186 INFO  [Camel Thread 0 -
ftp://localhost/inbox?move=done&password=camel123&username=camel]
[FtpPollingRoute]: Fetching  eclipse-jee-galileo-SR2-win32.zip
2010-05-28 16:36:28,466 INFO  [Camel Thread 0 -
ftp://localhost/inbox?move=done&password=camel123&username=camel]
[FtpPollingRoute]: eclipse-jee-galileo-SR2-win32.zip copied
2010-05-28 16:36:28,466 INFO  [Camel Thread 2 - OnCompletion]
[FtpPollingRoute]: onComplete =  false
2010-05-28 16:36:31,305 INFO  [Camel Thread 0 -
ftp://localhost/inbox?move=done&password=camel123&username=camel]
[FtpPollingRoute]: Fetching  isuite-checkout.jar
2010-05-28 16:36:31,336 INFO  [Camel Thread 0 -
ftp://localhost/inbox?move=done&password=camel123&username=camel]
[FtpPollingRoute]: isuite-checkout.jar copied
2010-05-28 16:36:31,336 INFO  [Camel Thread 3 - OnCompletion]
[FtpPollingRoute]: onComplete =  true
2010-05-28 16:36:31,336 INFO  [Camel Thread 3 - OnCompletion]
[FtpPollingRoute]: Stopping
2010-05-28 16:36:31,352 INFO  [Camel Thread 3 - OnCompletion]
[FtpPollingRoute]: Stopped
2010-05-28 16:36:31,352 ERROR [Camel Thread 0 -
ftp://localhost/inbox?move=done&password=camel123&username=camel]
[org.apache.camel.component.file.GenericFileOnCompletion]: Caused by:
[org.apache.camel.component.file.GenericFileOperationFailedException - File
operation failed:  Socket closed. Code: 221]
org.apache.camel.component.file.GenericFileOperationFailedException: File
operation failed:  Socket closed. Code: 221
        at
org.apache.camel.component.file.remote.FtpOperations.buildDirectory(FtpOperations.java:228)
        at
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.renameFile(GenericFileRenameProcessStrategy.java:85)
        at
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:72)
        at
org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:121)
        at
org.apache.camel.component.file.GenericFileOnCompletion.onCompletion(GenericFileOnCompletion.java:83)


that wraps a SocketException:

Caused by: java.net.SocketException: Socket closed
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at 
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)

-- 
View this message in context: 
http://old.nabble.com/Problems-shutting-down-route-onCompletion-tp28707903p28707903.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to