Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring integration 为什么邮件会卡在聚合器上?_Spring Integration - Fatal编程技术网

Spring integration 为什么邮件会卡在聚合器上?

Spring integration 为什么邮件会卡在聚合器上?,spring-integration,Spring Integration,消息从拆分器到聚合器需要20分钟到,有时需要一个小时 我有聚合器发送电子邮件到smtp在批处理。有时,消息需要很长时间才能从OmniAlertsEmailSplitter到达OmniAlertsEmailAdapter <!-- Split message into separate email messages for delivery --> <splitter id="omniAlertsEmailSplitter" input-channel="omni

消息从拆分器到聚合器需要20分钟到,有时需要一个小时

我有聚合器发送电子邮件到smtp在批处理。有时,消息需要很长时间才能从OmniAlertsEmailSplitter到达OmniAlertsEmailAdapter

<!-- Split message into separate email messages for delivery -->
<splitter id="omniAlertsEmailSplitter"
        input-channel="omniAlertsEmailDeliveryChannel"
        output-channel="omniAlertsEmailDeliveryProcessChannel" method="split">
        <beans:bean class="com.omnialerts.splitter.OmniAlertsEmailSplitter"> </beans:bean>
</splitter>

<!-- 
    the poller will process 1000 messages every second 
    if the size of the group is 1000 (the poll reached the max messages) or 1 seconds time out (poll has less than 1000 messages) then the payload with the list of messages is passed to defined output channel
-->
<aggregator input-channel="omniAlertsEmailDeliveryProcessChannel" output-channel="omniAlertsEmailDispatchChannel"
    discard-channel="omniAlertsEmailDispatchChannel"

    send-partial-result-on-expiry="true"
    group-timeout="1000"
    correlation-strategy-expression="T(Thread).currentThread().id"
    release-strategy-expression="size() == 1000">
    <poller max-messages-per-poll="1000" fixed-rate="1000"/>
</aggregator>
<channel id="omniAlertsEmailDeliveryProcessChannel">
     <queue/>
</channel>
<service-activator
        input-channel="omniAlertsEmailDispatchChannel"
        output-channel="omniAlertsEmailDeliveryStatusChannel" method="send">

        <beans:bean class="com.omnialerts.adapters.OmniAlertsEmailAdapter"> </beans:bean>
</service-activator>
<channel id="omniAlertsEmailDeliveryStatusChannel" />


它基本上工作正常,但在一些JVM上我注意到了这种延迟。可能是因为这些JVM上有一些额外的负载,但这不应该超过几秒钟。
配置中是否缺少某些内容?

您试图依靠
任务调度器
的轮询中包含
10
线程。这些线程可以在其他进程中使用,因此您的聚合器可能没有这么大的吸引力

我不知道立即拆分和聚合有什么意义,但是您可以考虑使用专用的<代码>任务执行器<代码> > <代码> <代码>,因此所有的聚合器任务都将在自己的线程池中执行。 还应考虑使用:

 <xsd:attribute name="expire-groups-upon-completion" default="false">
                <xsd:annotation>
                    <xsd:documentation>
                        Boolean flag specifying if MessageGroup should be removed once completed. Useful for
                        handling late arrival use cases where messages arriving with the correlationKey that
                        is the same as the completed MessageGroup will be discarded. Default is 'false'
                    </xsd:documentation>
                </xsd:annotation>
                <xsd:simpleType>
                    <xsd:union memberTypes="xsd:boolean xsd:string" />
                </xsd:simpleType>
            </xsd:attribute>

布尔标志,指定完成后是否应删除MessageGroup。有益于
处理延迟到达的用例,其中使用
与已完成的消息组相同,将丢弃该消息组。默认值为“false”

我使用了拆分器和聚合器,而不是
放弃频道

,因为我需要向SMTP发送一批1000封邮件。有更好的选择吗?轮询器上maxMessagesPerPoll=1000的QueueChannel,但之后仍然需要基于线程id的聚合器进行关联,并使用一些触发器释放未满组。不过,民意测验者的建议可以做到这一点,但看起来解决方案并不简单。新的
FluxAggregatorMessageHandler
应该更适合这个任务:我遵循了你(@artem bilan)的建议,对吧,但是没有关于消息被卡住的故事。如果处理任务的线程很忙,那么使用什么组件并不重要