1

Spring integration is working fine on a single node cluster. However the partitionStep is not getting completed and remains in STARTED state forever when we deploy our application on multiple nodes. It seems that PartitionStep is waiting in the receive method and never marks the step COMPLETED. Below is the configuration which I am using. Is there any way to start aggregator on master node only?

Master Configuration:

<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">t3://localhost:7001</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" auto-startup="false"/>

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

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

Slave Configuration:

<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">t3://localhost:7001</prop>
        </props>
    </property>
</bean>

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

<task:executor id="taskExecutor" pool-size="10" />

<int:channel id="requestsChannel">
    <int:dispatcher task-executor="taskExecutor" />
</int:channel>

<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:message-driven-channel-adapter connection-factory="connectionFactory" destination="reqQueue" channel="requestsChannel" />

<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:outbound-channel-adapter
    connection-factory="connectionFactory" destination="replyQueue" channel="replyChannel" />

<int:service-activator input-channel="requestsChannel"
    output-channel="replyChannel" ref="stepExecutionRequestHandler" />

Spring batch version 3.0.3 Spring core version 4.0.5 Spring integration version 4.0.1

  • We set `auto-startup="false"` on the message-driven channel adapter in master configuration and started it on the master node. However another issue is if another instance of the job is launched in parallel from second node then we will be back to square one. – Harvinder Bhutani Apr 20 '17 at 04:06
  • Another scenario is if another job instance is launched in parallel on the same node then how we ensure that the aggregator will aggregate messages pertain to the job launched? In gateways, it will ensure using JMSCorrelationID. Will it use JMSCorrelationID in adapters as well? We do not want to use gateways as gateways are synchronized and slow the performance. – Harvinder Bhutani Apr 20 '17 at 04:07
  • We have used JMS message selector in message-driven-channel-adapter **Master Configuration** `` and we have put `masterNodeName=2345-ab-itc` in message header. Now it stopped working even on single node. Why message selector is not working? – Harvinder Bhutani Apr 20 '17 at 14:57

0 Answers0