Spring集成 - 消息传递异常

时间:2015-10-20 16:55:28

标签: spring-integration

我们使用Spring Integration MessageChannel API将请求文件发布到FTP位置。在此过程中,文件已成功发送,但在此过程中我们收到MessageDeliveryException。 PFB堆栈跟踪供您参考。寻找解决方案。请指导。

注意:Exception表示它试图删除,但我们并没有尝试删除。

2015-10-13 08:33:26.000439 [INFO] [task-scheduler-8] | com.dnb.fatca.service.impl.FTPChannelManagerImpl | isSuccess Val........false
2015-10-13 08:33:26.000439 [ERROR] [task-scheduler-8] | com.dnb.fatca.service.impl.FTPChannelManagerImpl | Error handling message for file [/dnbusr2/fatca/temp/execution/batch/8293/8293.APN -> 8293.APN]
org.springframework.integration.MessageDeliveryException: Error handling message for file [/dnbusr2/fatca/temp/execution/batch/8293/8293.APN -> 8293.APN]
       at org.springframework.integration.file.remote.RemoteFileTemplate$1.doInSession(RemoteFileTemplate.java:227)
       at org.springframework.integration.file.remote.RemoteFileTemplate$1.doInSession(RemoteFileTemplate.java:190)
       at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:297)
       at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:190)
       at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:182)
       at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:112)
       at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
       at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
       at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
       at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
       at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:178)
       at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:149)
       at com.dnb.fatca.service.impl.FTPChannelManagerImpl.pushFileToChannel(FTPChannelManagerImpl.java:309)
       at com.dnb.fatca.service.impl.FTPChannelManagerImpl.pushToGBFChannelFTP(FTPChannelManagerImpl.java:209)
       at com.dnb.fatca.batch.tasklet.GBFInputDataSender.execute(GBFInputDataSender.java:222)
       at sun.reflect.GeneratedMethodAccessor201.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:606)
       at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
       at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
       at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
       at com.sun.proxy.$Proxy43.execute(Unknown Source)
       at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
       at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
       at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
       at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271)
       at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:77)
       at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:368)
       at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
       at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
       at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257)
       at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:198)
       at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
       at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64)
       at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67)
       at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:162)
       at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:141)
       at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:134)
       at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:304)
       at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135)
       at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
       at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128)
       at com.dnb.fatca.batch.trigger.GBSResponseMQTrigger.triggerGBSResponse(GBSResponseMQTrigger.java:405)
       at sun.reflect.GeneratedMethodAccessor933.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:606)
       at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:63)
       at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:95)
       at org.springframework.expression.spel.ast.MethodReference.access$000(MethodReference.java:44)
       at org.springframework.expression.spel.ast.MethodReference$MethodValueRef.getValue(MethodReference.java:258)
       at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:84)
       at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:114)
       at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:111)
       at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:144)
       at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:268)
       at org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:142)
       at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:73)
       at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:67)
       at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:142)
       at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
       at org.springframework.integration.endpoint.PollingConsumer.handleMessage(PollingConsumer.java:74)
       at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:199)
       at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:51)
       at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:143)
       at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:141)
       at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:273)
       at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
       at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
       at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
       at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:268)
       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
       at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
       at java.util.concurrent.FutureTask.run(FutureTask.java:262)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
       at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.integration.MessagingException: Failed to write to '/puts/8293.APN.writing' while uploading the file
       at org.springframework.integration.file.remote.RemoteFileTemplate.sendFileToRemoteDirectory(RemoteFileTemplate.java:392)
       at org.springframework.integration.file.remote.RemoteFileTemplate.access$500(RemoteFileTemplate.java:56)
       at org.springframework.integration.file.remote.RemoteFileTemplate$1.doInSession(RemoteFileTemplate.java:213)
       ... 82 more
****Caused by: org.springframework.core.NestedIOException: Failed to delete file /puts/8293.APN; nested exception is org.springframework.core.NestedIOException: Failed to remove file: 3: Permission denied**.**
       at org.springframework.integration.sftp.session.SftpSession.rename(SftpSession.java:200)
       at org.springframework.integration.file.remote.RemoteFileTemplate.sendFileToRemoteDirectory(RemoteFileTemplate.java:388)
       ... 84 more
Caused by: org.springframework.core.NestedIOException: Failed to remove file: 3: Permission denied.
       at org.springframework.integration.sftp.session.SftpSession.remove(SftpSession.java:83)
       at org.springframework.integration.sftp.session.SftpSession.rename(SftpSession.java:194)
       ... 85 more
2015-10-13 08:33:26.000441 [INFO] [task-scheduler-8] | com.dnb.fatca.service.impl.FTPChannelManagerImpl | Message '[/dnbusr2/fatca/temp/execution/batch/8293/8293.APN]' Sent Status : false
2015-10-13 08:33:26.000480 [INFO] [task-scheduler-8] | com.dnb.fatca.batch.listeners.AppendDataRequestPPListener | 8293Execution completed

1 个答案:

答案 0 :(得分:0)

让我们来看看StackTrace的近距离!

Caused by: org.springframework.core.NestedIOException: Failed to remove file: 3: Permission denied.
       at org.springframework.integration.sftp.session.SftpSession.remove(SftpSession.java:83)
       at org.springframework.integration.sftp.session.SftpSession.rename(SftpSession.java:194)

所以,完全通过rename你做remove :-)。 这是因为:

if (logger.isDebugEnabled()) {
    logger.debug("Initial File rename failed, possibly because file already exists. Will attempt to delete file: "
                + pathTo + " and execute rename again.");
}

我猜你也没有权限重命名文件。 rename操作仅在RemoteFileTemplate时从useTemporaryFileName == true启动。

因此,要解决您的问题,请尝试将其配置为use-temporary-file-name="false"上的<int-sftp:outbound-channel-adapter>