Announcement Announcement Module
Collapse
No announcement yet.
IGNORE mode outbound-channel-adapter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • IGNORE mode outbound-channel-adapter

    Hi,

    I have a quick question about the mode 'IGNORE' for the outbound-channel-adaper

    I have configured the following outbound-channel-adapter

    Code:
    <int-file:outbound-channel-adapter auto-create-directory="false" directory="${stagingDirectory}" id="stagingFileId" mode="IGNORE"/>
    We always run two instances of the same application at the same time for failover purposes. It can happen that both processes try to write a file with the same name at the same time (cron expression) to the same directory. I've added the "IGNORE" flag so that basicially the first one to do the write wins. I've been noticing lately that we are getting some weird exceptions that I can't explain such as:
    Caused by: java.io.IOException: Failed to rename file '/appl/xyz/myfile.txt.writing' to '/appl/xyz/myfile.txt'

    org.springframework.integration.MessageHandlingExc eption: java.io.IOException: Failed to rename file '/appl/xyz/myfile.txt.writing' to '/appl/xyz/myfile.txt'
    at org.springframework.integration.handler.MethodInvo kingMessageProcessor.processMessage(MethodInvoking MessageProcessor.java:76)
    at org.springframework.integration.handler.ServiceAct ivatingHandler.handleRequestMessage(ServiceActivat ingHandler.java:67)
    at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.handleMessageInternal(A bstractReplyProducingMessageHandler.java:134)
    at org.springframework.integration.handler.AbstractMe ssageHandler.handleMessage(AbstractMessageHandler. java:73)
    at org.springframework.integration.dispatcher.Broadca stingDispatcher.invokeHandler(BroadcastingDispatch er.java:121)
    at org.springframework.integration.dispatcher.Broadca stingDispatcher.dispatch(BroadcastingDispatcher.ja va:112)
    at org.springframework.integration.channel.AbstractSu bscribableChannel.doSend(AbstractSubscribableChann el.java:77)
    at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:157)
    at org.springframework.integration.channel.MessagePub lishingErrorHandler.handleError(MessagePublishingE rrorHandler.java:83)
    at org.springframework.integration.util.ErrorHandling TaskExecutor$1.run(ErrorHandlingTaskExecutor.java: 55)
    at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
    at org.springframework.integration.util.ErrorHandling TaskExecutor.execute(ErrorHandlingTaskExecutor.jav a:49)
    at org.springframework.integration.endpoint.AbstractP ollingEndpoint$Poller.run(AbstractPollingEndpoint. java:231)
    at org.springframework.scheduling.support.DelegatingE rrorHandlingRunnable.run(DelegatingErrorHandlingRu nnable.java:53)
    at java.util.concurrent.Executors$RunnableAdapter.cal l(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRunAndRe set(FutureTask.java:317)
    at java.util.concurrent.FutureTask.runAndReset(Future Task.java:150)
    at org.springframework.scheduling.commonj.TimerManage rTaskScheduler$TimerScheduledFuture.timerExpired(T imerManagerTaskScheduler.java:117)
    at org.springframework.scheduling.commonj.TimerManage rTaskScheduler$ReschedulingTimerListener.timerExpi red(TimerManagerTaskScheduler.java:170)
    at com.ibm.ws.asynchbeans.timer.TimerImpl.callListene rMethod(TimerImpl.java:298)
    at com.ibm.ws.asynchbeans.timer.GenericTimer.run(Gene ricTimer.java:216)
    at com.ibm.ws.asynchbeans.J2EEContext$RunProxy.run(J2 EEContext.java:264)
    at java.security.AccessController.doPrivileged(Access Controller.java:224)
    at javax.security.auth.Subject.doAs(Subject.java:495)
    at com.ibm.websphere.security.auth.WSSubject.doAs(WSS ubject.java:131)
    at com.ibm.websphere.security.auth.WSSubject.doAs(WSS ubject.java:89)
    at com.ibm.ws.asynchbeans.J2EEContext$DoAsProxy.run(J 2EEContext.java:335)
    at java.security.AccessController.doPrivileged(Access Controller.java:251)
    at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext .java:1146)
    at com.ibm.ws.asynchbeans.timer.TimerImpl.runListener AsCJWork(TimerImpl.java:425)
    at com.ibm.ws.asynchbeans.am._Alarm.fireAlarm(_Alarm. java:333)
    at com.ibm.ws.asynchbeans.am._Alarm.run(_Alarm.java:2 30)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava:1613)
    Caused by: java.io.IOException: Failed to rename file '/appl/xyz/myfile.txt.writing' to '/appl/xyz/myfile.txt'
    at org.springframework.integration.file.FileWritingMe ssageHandler.renameTo(FileWritingMessageHandler.ja va:432)
    at org.springframework.integration.file.FileWritingMe ssageHandler.cleanUpAfterCopy(FileWritingMessageHa ndler.java:417)
    at org.springframework.integration.file.FileWritingMe ssageHandler.handleStringMessage(FileWritingMessag eHandler.java:391)
    at org.springframework.integration.file.FileWritingMe ssageHandler.handleRequestMessage(FileWritingMessa geHandler.java:284)
    at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.handleMessageInternal(A bstractReplyProducingMessageHandler.java:134)
    at org.springframework.integration.handler.AbstractMe ssageHandler.handleMessage(AbstractMessageHandler. java:73)
    at org.springframework.integration.dispatcher.Unicast ingDispatcher.doDispatch(UnicastingDispatcher.java :115)
    at org.springframework.integration.dispatcher.Unicast ingDispatcher.dispatch(UnicastingDispatcher.java:1 02)
    at org.springframework.integration.channel.AbstractSu bscribableChannel.doSend(AbstractSubscribableChann el.java:77)
    at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:157)
    at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:128)
    at org.springframework.integration.core.MessagingTemp late.doSend(MessagingTemplate.java:288)
    at org.springframework.integration.core.MessagingTemp late.send(MessagingTemplate.java:149)
    at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.sendMessage(AbstractRep lyProducingMessageHandler.java:216)
    at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.sendReplyMessage(Abstra ctReplyProducingMessageHandler.java:200)
    at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.produceReply(AbstractRe plyProducingMessageHandler.java:165)
    at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.handleResult(AbstractRe plyProducingMessageHandler.java:159)
    at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.handleMessageInternal(A bstractReplyProducingMessageHandler.java:141)
    at org.springframework.integration.handler.AbstractMe ssageHandler.handleMessage(AbstractMessageHandler. java:73)
    at org.springframework.integration.dispatcher.Unicast ingDispatcher.doDispatch(UnicastingDispatcher.java :115)
    at org.springframework.integration.dispatcher.Unicast ingDispatcher.dispatch(UnicastingDispatcher.java:1 02)
    at org.springframework.integration.channel.AbstractSu bscribableChannel.doSend(AbstractSubscribableChann el.java:77)
    at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:157)
    at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:128)
    at org.springframework.integration.core.MessagingTemp late.doSend(MessagingTemplate.java:288)
    at org.springframework.integration.core.MessagingTemp late.send(MessagingTemplate.java:149)
    at org.springframework.integration.endpoint.SourcePol lingChannelAdapter.handleMessage(SourcePollingChan nelAdapter.java:97)
    at org.springframework.integration.endpoint.AbstractT ransactionSynchronizingPollingEndpoint.doPoll(Abst ractTransactionSynchronizingPollingEndpoint.java:8 2)
    at org.springframework.integration.endpoint.AbstractP ollingEndpoint$1.call(AbstractPollingEndpoint.java :146)
    at org.springframework.integration.endpoint.AbstractP ollingEndpoint$1.call(AbstractPollingEndpoint.java :144)
    at org.springframework.integration.endpoint.AbstractP ollingEndpoint$Poller$1.run(AbstractPollingEndpoin t.java:236)
    at org.springframework.integration.util.ErrorHandling TaskExecutor$1.run(ErrorHandlingTaskExecutor.java: 52)
    ... 23 more
    I took a look at the code for the outbound-channel-adapter (FileWritingMessageHandler, at least I think this is it) and saw the following code to determine if it should ignore a file or not:

    Code:
    final boolean ignore = FileExistsMode.IGNORE.equals(this.fileExistsMode) && resultFile.exists();
    but..I had expected this (that it also checks for the temp '.writing' version of this file):

    Code:
    final boolean ignore = FileExistsMode.IGNORE.equals(this.fileExistsMode) && ( resultFile.exists() || tempFile.exists());
    Is this an incorrect assumption? Could this be the source of the exceptions?

  • #2
    Yes, it looks like a bug to me; please open a JIRA issue. https://jira.springsource.org/browse/INT

    As a work-around, you could add an ExpressionEvaluatingRequestHandlerAdvice to handle the exception by sending the ErrorMessage to a failureChannel, detect the exception and ignore it (if it's this) or rethrow it if it's something else.

    The retry-and-more sample has an example of using this advice.

    Comment


    • #3
      Added:

      https://jira.springsource.org/browse/INT-3089

      Comment

      Working...
      X