我花了几个月的时间才最终使用ActiveMQ作为代理在SBF中进行远程分区。但我无法正常工作。
如果我将MessageChannelPartitionHandler上的网格大小设置为4,那么我预计4个从属将执行4个网格中的一个。如果只有3个奴隶那么这个步骤就会失败。
然而,使用4个网格和1个从属进行测试,单个从属处理所有4个网格!主配置和从配置如下。
有谁知道如何配置SBF,以便离散从站处理离散网格?现在我想我必须扩展MessageChannelPartitionHandler,以便为每个网格创建一个新的MessagingTemplate,每个模板对每个唯一的slave都有一个唯一的requestChannel。这是正确的方向吗?
站长:
<bean id="partitionHandler" class="org.springframework.batch.integration.partition.MessageChannelPartitionHandler">
<property name="stepName" value="processStates.slave" />
<property name="gridSize" value="4" />
<property name="replyChannel" ref="aggregatedReplyChannel" />
<property name="messagingOperations">
<bean class="org.springframework.integration.core.MessagingTemplate">
<property name="defaultChannel" ref="requestsChannel" />
</bean>
</property>
</bean>
<int-jms:outbound-channel-adapter
connection-factory="connectionFactory" channel="requestsChannel"
destination-name="grid1" />
<int:channel id="requestsChannel" />
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
p:brokerURL="${broker.url}">
<property name="trustAllPackages" value="true" />
</bean>
从站:
<batch:step id="processStates.slave">
<batch:tasklet task-executor="taskExecutor">
<batch:chunk reader="itemReader" processor="itemProcessor"
writer="itemWriter" commit-interval="500" />
</batch:tasklet>
</batch:step>
<bean id="taskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="2" />
<property name="maxPoolSize" value="2" />
<property name="WaitForTasksToCompleteOnShutdown" value="true" />
</bean>
<int-jms:message-driven-channel-adapter
connection-factory="connectionFactory" destination-name="requestsQueue"
channel="grid1" />
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
p:brokerURL="${broker.url}">
<property name="trustAllPackages" value="true" />
</bean>
经纪人:
BrokerService brokerService = new BrokerService();
brokerService.setUseJmx(false);
// brokerService.setAdvisorySupport(false);
// brokerService.setSchedulerSupport(false);
// brokerService.setBrokerName("broker");
// brokerService.setUseShutdownHook(false);
// brokerService.setPersistent(false);
brokerService.addConnector(addr);
brokerService.start();
Object lock = new Object();
synchronized (lock) {
lock.wait();
}