为什么消息停留在聚合器上?

时间:2019-09-13 17:34:39

标签: spring-integration

消息从拆分器到聚合有时需要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上有一些额外的负载,但是它应该花不了几秒钟。 我在配置中缺少什么吗?

1 个答案:

答案 0 :(得分:0)

您尝试在其民意测验中依靠TaskScheduler线程中的10线程。这些线程可以在其他进程中使用,因此您的聚合器可能没有那么多吸引力。

我不确定立即拆分和聚合的目的是什么,但是您可以考虑为此task-executor使用专用的<poller>,因此所有聚合器任务都将在其中执行它自己的线程池。

还考虑使用:

 <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>

代替discard-channel