Spring batch Spring集成-生产者队列容量限制

Spring batch Spring集成-生产者队列容量限制,spring-batch,spring-integration,spring-messaging,Spring Batch,Spring Integration,Spring Messaging,Spring集成-生产者队列容量限制 我们正在使用带有MessageChannelPartitionHandler的远程分区将分区消息发送到队列(ActiveMQ),以便挑选和处理工作人员。 作业有大量数据要处理,许多分区消息正在发布到队列,来自ReplyChannel的响应聚合器由于消息超时而失败,因为在给定的时间内无法处理所有消息。 我们还试图通过使用队列容量来限制发布到队列中的消息,这会导致服务器崩溃,并由于保存所有这些分区消息的内存问题而生成堆转储 在内存中 我们希望控制StepExec

Spring集成-生产者队列容量限制

我们正在使用带有MessageChannelPartitionHandler的远程分区将分区消息发送到队列(ActiveMQ),以便挑选和处理工作人员。 作业有大量数据要处理,许多分区消息正在发布到队列,来自ReplyChannel的响应聚合器由于消息超时而失败,因为在给定的时间内无法处理所有消息。 我们还试图通过使用队列容量来限制发布到队列中的消息,这会导致服务器崩溃,并由于保存所有这些分区消息的内存问题而生成堆转储 在内存中

我们希望控制StepExecution split本身的创建,这样就不会出现内存问题。 例如,大约4k分区消息被发布到队列中,整个作业大约需要3小时

我们可以控制消息发布到QueueChannel吗

<bean id="senExtractMemberMasterPartitionHandler"   class="org.springframework.batch.integration.partition.MessageChannelPartitionHandler">
        <property name="messagingOperations" ref="senExtractMemberMasterPartitionMsgTemplate" />
        <property name="replyChannel" ref="senExtractProcessingMasterAggregatedChannel" />
        <property name="stepName" value="senExtractGeneratePrintRequestWorkerStep" />
        <property name="gridSize" value="500" />
</bean>
<bean id="senExtractMemberMasterPartitionMsgTemplate" class="org.springframework.integration.core.MessagingTemplate">
    <property name="defaultChannel" ref="senExtractProcessingMasterRequestChannel" />
    <property name="receiveTimeout" value="18000000" />
</bean>

<integration:channel id="senExtractProcessingMasterAggregatedChannel" >
    <integration:queue />
    <integration:interceptors>
        <integration:wire-tap channel="masterLoggingChannel" />
    </integration:interceptors>
</integration:channel>


<int-jms:outbound-gateway
    id="senExtractMasterOutGateway" 
    connection-factory="masterJMSConnectionFactory"
    correlation-key="JMSCorrelationID"
    request-channel="senExtractProcessingMasterRequestChannel"
    request-destination-name="senExtractRequestQueue" 
    reply-channel="senExtractProcessingMasterReplyChannel"
    reply-destination-name="senExtractReplyQueue" 
    async="true"
    auto-startup="true"
    reply-timeout="18000000" 
    receive-timeout="6000">
    <integration:poller ref="masterPoller"/>
    <int-jms:reply-listener />  
</int-jms:outbound-gateway>

作业有大量数据要处理,许多分区消息正在发布到队列,来自ReplyChannel的响应聚合器由于消息超时而失败,因为在给定的时间内无法处理所有消息

您需要增加超时时间或添加更多工作人员。的Javadoc清楚地说明了这一点:

The receive timeout needs to be set realistically in the MessagingTemplate
and the aggregator, so that there is a good chance of all work being done.
我们想控制StepExecution拆分本身的创建

SpringBatch为此提供了接口。如果默认的(
simplestepexecutionspliter
)不适合您的需要,您可以为分区步骤提供自定义实现