部署在2节点集群上时,分区步骤仍处于启动状态

时间:2017-04-17 17:20:06

标签: spring-integration spring-batch

我有一个QueueChannel,它是我的聚合器的输出通道。代码在单节点集群上运行良好。此刻,我将它部署在2节点集群上,partitionStep未完成并永远保持在STARTED状态。看看PartitionStep它似乎在receive方法中等待,并且从未标记步骤COMPLETED。以下是我正在使用的配置。

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
                <prop key="java.naming.provider.url">${oag_wl_nodes_url}</prop>
            </props>
        </property>
    </bean>

    <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jndiTemplate" />
        <property name="jndiName" value="jmsConnectionFactory" />
    </bean>

    <int:channel id="requestsChannel" />

    <bean id="reqQueue" class="org.springframework.jndi.JndiObjectFactoryBean"
        lazy-init="true" scope="prototype">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="jndiName">
            <value>masterRequestQueue</value>
        </property>
    </bean>

    <int-jms:outbound-channel-adapter
        connection-factory="connectionFactory" channel="requestsChannel" destination="reqQueue" />

    <int:channel id="replyChannel" />

    <bean id="replyQueue" class="org.springframework.jndi.JndiObjectFactoryBean"
        lazy-init="true" scope="prototype">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="jndiName">
            <value>masterReplyQueue</value>
        </property>
    </bean>

    <int-jms:message-driven-channel-adapter connection-factory="connectionFactory" destination="replyQueue" 
            channel="replyChannel" acknowledge="transacted" />

    <int:channel id="aggregatedReplyChannel">
        <int:queue />
    </int:channel>

    <int:aggregator ref="partitionHandler" 
            input-channel="replyChannel" output-channel="aggregatedReplyChannel" />

1 个答案:

答案 0 :(得分:0)

您正在使用公共回复队列replyQueue;这将无效,因为两个实例正在竞争回复,并且回复可能会被非主节点使用。

每个人都需要一个单独的回复目的地。

那就是说,我没有看到你在出站信息上设置了回复,所以我认为你的回复在消费者方面是硬编码的..

您可能会发现使用出站网关而不是一对通道适配器更容易;网关将为每个请求创建一个临时应答队列(默认情况下)。