配置Spring集成。 ErrorHandlingTaskExecutor

时间:2019-03-06 10:09:58

标签: spring-integration

<context:annotation-config/>
<context:component-scan base-package="ru.*"/>

<int:poller id="defaultPoller" default="true"
            fixed-delay="1000" task-executor="taskExecutor"/>
<task:executor id="taskExecutor" pool-size="1-5" queue-capacity="200" rejection-policy="CALLER_RUNS"/>

<int:channel id="listFiles">
    <int:queue capacity="1000"/>
</int:channel>

<int:channel id="pages">
    <int:queue capacity="1000"/>
</int:channel>

<int:channel id="resultWithHeader">
    <int:queue capacity="1000"/>
</int:channel>

<int:channel id="toBD">
    <int:queue capacity="1000"/>
</int:channel>

<int:channel id="unparsedToUniq">
    <int:queue capacity="1000"/>
</int:channel>

<task:scheduled-tasks>
    <task:scheduled ref="getFilesList"
                    method="getList"
                    cron="0 0 12 * * WED"/>
</task:scheduled-tasks>

<int:splitter id="splitterPdf" ref="split" method="receive" input-channel="listFiles" output-channel="pages"/>

<int:transformer id="transfMain" input-channel="pages" ref="firstTransform" method="transform"
                 output-channel="resultWithHeader"/>

<int:header-value-router id="routedParsingDocument" input-channel="resultWithHeader" header-name="parsed">
    <int:mapping value="yes" channel="toBD"/>
    <int:mapping value="no" channel="unparsedToUniq"/>
</int:header-value-router>

<int:transformer id="transfUniq" input-channel="unparsedToUniq" ref="secondTransform" method="transform"
                 output-channel="toBD"/>

<int:service-activator id="bd_activator" input-channel="toBD" method="receive" ref="bd" > <int:poller task-executor="taskBD" fixed-delay="1500"/></int:service-activator>

<bean id="getFilesList" class="ru.*.GetAndReadFiles"/>

<bean id="split" class="ru.*.SplitDocument"/>

<bean id="firstTransform" class="ru.*.MainParser"/>

<bean id="secondTransform" class="ru.*.UniqParser"/>

<bean id="bd" class="ru.*.BDWriter"/>

<task:executor id="taskBD" pool-size="1-10" queue-capacity="100" rejection-policy="CALLER_RUNS"/>

你好 程序读取目录中的所有文件,拆分页面,转换信息(主要或uniq)并将信息写入基址。

我对此配置有疑问。

06-03-2019 13:01:24.773 [task-scheduler-7] ERROR o.s.i.handler.LoggingHandler.handleMessageInternal - org.springframework.core.task.TaskRejectedException: Executor [java.util.concurrent.ThreadPoolExecutor@19c520db[Running, pool size = 5, active threads = 5, queued tasks = 200, completed tasks = 1353]] did not accept task: org.springframework.integration.util.ErrorHandlingTaskExecutor$$Lambda$241/1065676784@6991f347

我在做什么错?如果我不使用taskExecutor,请编写程序。但是我需要提高执行速度。在其他配置工作中<,但我遇到了这个问题:ERROR o.s.i.handler.LoggingHandler.handleMessageInternal - java.lang.OutOfMemoryError: Java heap space 感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

您应该考虑在两者之间不使用队列通道。足够将轮询结果从轮询器分发到该taskExecutor中。

不过,您可以在splitter之后留下一个队列通道,因为拆分后您将拥有一对多的通道,因此使它们并行是非常好的。尽管您也可以考虑在其中使用ExecutorChannel

不过,由于政策为CALLER_RUNS ...,为什么不清楚您为什么拒绝任务?