Spring-batch + Integration DSL throw在作业结束后找不到Dispatcher异常

时间:2017-12-15 19:58:50

标签: spring-integration spring-batch

我已经实现了Spring Batch + Spring Integration与DSL的结合,参考以下链接

https://github.com/cppwfs/spring-batch/blob/1f7cada52aba95bcb23d06bc034b21fe1de0a7a5/spring-batch-docs/asciidoc/spring-batch-integration.adoc#launching-batch-jobs-through-messages

这是代码。

@Bean
public IntegrationFlow integrationFlowUi(JobLaunchingGateway jobLaunchingGateway) {
    return IntegrationFlows.from(Files.inboundAdapter(new File(incomingDirUi)).
                    filter(new SimplePatternFileListFilter("*.csv")).
                    filter(new AcceptOnceFileListFilter<>()),
            c -> c.poller(Pollers.fixedRate(500).maxMessagesPerPoll(1))).
            channel("bridgeChannel").
            handle(fileMessageToJobRequest()).
            handle(jobLaunchingGateway).
            log(LoggingHandler.Level.WARN, "headers.id + ': ' + payload").
            get();
}

批量配置为

@Bean
public Job fundingCardActivationJob() {
    return jobBuilderFactory.get("fundingCardActivationJob")
            .incrementer(new RunIdIncrementer())
            .flow(activationStep())
            .next(fileRenamingStep())
            .end()
            .build();
}

工作运行。但最后它抛出了异常。

2017-12-15 12:39:54.867  WARN 13723 --- [ask-scheduler-1] headers.id + ': ' + payload              : GenericMessage [payload=JobExecution: id=572, version=2, startTime=Fri Dec 15 12:39:52 PST 2017, endTime=Fri Dec 15 12:39:54 PST 2017, lastUpdated=Fri Dec 15 12:39:54 PST 2017, status=COMPLETED, exitStatus=exitCode=COMPLETED;exitDescription=, job=[JobInstance: id=348, version=0, Job=[fundingCardActivationJob]], jobParameters=[{input.file.name=/Users/sudhir/ui/fundactive_2748_4444444444444444_2017-11-17_12-12-20.018.csv}], headers={id=4dcafdd0-aaed-ff62-bed9-781db41dfdf2, timestamp=1513370394863}]
  

2017-12-15 12:39:54.900 ERROR 13723 --- [ask-scheduler-1] osintegration.handler.LoggingHandler:org.springframework.messaging.MessageDeliveryException:Dispatcher没有订阅者频道&#39; application.integrationFlowUi.channel#2&#39;。嵌套异常是org.springframework.integration.MessageDispatchingException:Dispatcher没有订阅者,failedMessage = GenericMessage [payload = JobExecution:id = 572,version = 2,startTime = Fri Dec 15 12:39:52 PST 2017,endTime = Fri Dec 15太平洋标准时间12:39:54 2017年,lastUpdated = Fri 12月15日12:39:54太平洋标准时间2017年,status = COMPLETED,exitStatus = exitCode = COMPLETED; exitDescription =,job = [JobInstance:id = 348,version = 0,Job = [ fundingCardActivationJob]],jobParameters = [{input.file.name = / Users / sudhir / ui / fundactive_2748_4444444444444444_2017-11-17_12-12-20.018.csv}],headers = {id = 4dcafdd0-aaed-ff62-bed9-781db41dfdf2, timestamp = 1513370394863}],failedMessage = GenericMessage [payload = JobExecution:id = 572,version = 2,startTime = Fri Dec 15 12:39:52 PST 2017,endTime = Fri Dec 15 12:39:54 PST 2017,lastUpdated =太平洋标准时间12月15日12:39:54太平洋标准时间2017年,状态=已完成,exitStatus = exitCode = COMPLETED; exitDescription =,job = [JobInstance:id = 348,version = 0,Job = [fundingCardActivationJob]],jobParameters = [{input。 file.name = /用户/ sudhi r / ui / fundactive_2748_4444444444444444_2017-11-17_12-12-20.018.csv}],headers = {id = 4dcafdd0-aaed-ff62-bed9-781db41dfdf2,timestamp = 1513370394863}]       在org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:93)       在org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:425)       在org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:375)       在org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)       在org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)       在org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105)       在org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:360)       在org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:271)       在org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:188)       在org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:115)       在org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)       在org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)       在org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148)       在org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121)       在org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:89)       在org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:425)       在org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:375)       在org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)       在org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)       在org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105)       在org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:360)       在org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:271)       在org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:188)       在org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:115)       在org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)       在org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)       在org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148)       在org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121)       在org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:89)       在org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:425)       在org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:375)       在org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)       在org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)       在org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105)       在org.springframework.integration.endpoint.SourcePollingChannelAdapter.handleMessage(SourcePollingChannelAdapter.java:210)       在org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:272)       在org.springframework.integration.endpoint.AbstractPollingEndpoint.access $ 000(AbstractPollingEndpoint.java:58)       在org.springframework.integration.endpoint.AbstractPollingEndpoint $ 1.call(AbstractPollingEndpoint.java:190)       在org.springframework.integration.endpoint.AbstractPollingEndpoint $ 1.call(AbstractPollingEndpoint.java:186)       在org.springframework.integration.endpoint.AbstractPollingEndpoint $ Poller $ 1.run(AbstractPollingEndpoint.java:353)       在org.springframework.integration.util.ErrorHandlingTaskExecutor $ 1.run(ErrorHandlingTaskExecutor.java:55)       在org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)       在org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51)       在org.springframework.integration.endpoint.AbstractPollingEndpoint $ Poller.run(AbstractPollingEndpoint.java:344)       在org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)       在org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)       at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)       at java.util.concurrent.FutureTask.run(FutureTask.java:266)       at java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.access $ 201(ScheduledThreadPoolExecutor.java:180)       at java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)       在java.lang.Thread.run(Thread.java:745)   引起:org.springframework.integration.MessageDispatchingException:Dispatcher没有订阅者,failedMessage = GenericMessage [payload = JobExecution:id = 572,version = 2,startTime = Fri Dec 15 12:39:52 PST 2017,endTime = Fri Dec 15太平洋标准时间12:39:54 2017年,lastUpdated = Fri 12月15日12:39:54太平洋标准时间2017年,status = COMPLETED,exitStatus = exitCode = COMPLETED; exitDescription =,job = [JobInstance:id = 348,version = 0,Job = [ fundingCardActivationJob]],jobParameters = [{input.file.name = / Users / sudhir / ui / fundactive_2748_4444444444444444_2017-11-17_12-12-20.018.csv}],headers = {id = 4dcafdd0-aaed-ff62-bed9-781db41dfdf2,时间戳= 1513370394863}]       在org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:154)       在org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121)       在org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:89)       ... 52更多

我不知道为什么在集成配置似乎完成时会抛出异常。

1 个答案:

答案 0 :(得分:0)

JobExecution结果发送到.log()之前,某事正在关闭(或停止)应用程序上下文。