title: spring batch remote chunking doesn't queue messages but runs it locally?
body: <p>Below is my configuration for spring batch remote chunking. My steps are running locally instead of remotely. I cant see messages in rabbitmq. </p>
  
  <pre><code>&lt;beans:bean id="importExchangesChunkItemWriter"
      class="org.springframework.batch.integration.chunk.ChunkMessageChannelItemWriter"
      scope="step" p:messagingOperations-ref="importExchangesMessagingTemplate"
      p:replyChannel-ref="importExchangesReplyChannel"&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="importExchangesChunkHandler"
      class="org.springframework.batch.integration.chunk.RemoteChunkHandlerFactoryBean"
      p:chunkWriter-ref="importExchangesChunkItemWriter" p:step-ref="importExchangesStep"&gt;
  &lt;/beans:bean&gt;
  
  &lt;job id="importExchangesJob" restartable="true"&gt;    
       &lt;step id="importExchangesStep" next="importEclsStep"&gt;
          &lt;tasklet transaction-manager="transactionManager"&gt;
              &lt;chunk reader="importExchangesFileItemReader" writer="importExchangesItemWriter"
                  commit-interval="${import.exchanges.commit.interval}" /&gt;
          &lt;/tasklet&gt;
      &lt;/step&gt;    
    &lt;/job&gt;
  
  
  
  &lt;beans:bean id="passThroughItemProcessor" class="org.springframework.batch.item.support.PassThroughItemProcessor" /&gt;
  
  &lt;rabbit:connection-factory id="connectionFactory"
      port="${rabbitmq.port}" host="${rabbitmq.host}" username="${rabbitmq.username}"
      password="${rabbitmq.password}" /&gt;
  
  &lt;rabbit:template id="amqpTemplate" connection-factory="connectionFactory" /&gt;
  
  &lt;rabbit:admin id="rmqAdmin" connection-factory="connectionFactory" /&gt;
  
  &lt;rabbit:queue name="${import.exchanges.queue}" /&gt;
  &lt;rabbit:queue name="${import.exchanges.reply.queue}" /&gt;
  
  &lt;int:channel id="importExchangesChannel" /&gt;
  
  
  &lt;int:channel id="importExchangesReplyChannel" /&gt;
  
  
  &lt;beans:bean id="importExchangesMessagingTemplate"
      class="org.springframework.integration.core.MessagingTemplate"
      p:defaultChannel-ref="importExchangesChannel" p:receiveTimeout="${import.exchanges.reply.timeout}" /&gt;
  
  &lt;amqp:outbound-channel-adapter id="importExchangesOutboundAdapter"
      channel="importExchangesChannel" /&gt;
  
  &lt;amqp:inbound-channel-adapter id="importExchangesInboundAdapter"
      connection-factory="connectionFactory" channel="importExchangesReplyChannel"
      queue-names="${import.exchanges.reply.queue}" /&gt;
  
  
  &lt;amqp:inbound-channel-adapter id="importExchangesSlaveInboundAdapter"
      connection-factory="connectionFactory" channel="importExchangesChannel"
      queue-names="${import.exchanges.queue}" /&gt;
  
  
  
  &lt;amqp:outbound-channel-adapter id="importExchangesSlaveOutboundAdapter"
      channel="importExchangesReplyChannel" /&gt;
  
  &lt;int:service-activator id="serviceActivatorExchanges"
      input-channel="importExchangesChannel" output-channel="importExchangesReplyChannel"
      ref="chunkProcessorChunkHandlerExchanges" method="handleChunk" /&gt;
  
  
  &lt;beans:bean id="importExchangesItemWriter"
      class="com.st.batch.foundation.ImportExchangesItemWriter" p:symfony-ref="symfony" p:replyTimeout="${import.exchanges.reply.timeout}"/&gt;
  
  
  
  &lt;beans:bean id="chunkProcessorExchanges"
      class="org.springframework.batch.core.step.item.SimpleChunkProcessor"
      p:itemWriter-ref="importExchangesItemWriter" p:itemProcessor-ref="passThroughItemProcessor"/&gt;
  
  &lt;beans:bean id="chunkProcessorChunkHandlerExchanges"
      class="org.springframework.batch.integration.chunk.ChunkProcessorChunkHandler"
      p:chunkProcessor-ref="chunkProcessorExchanges" /&gt;
  </code></pre>
  
  <p>Changed configuration to this, now it queue single message at a time and doesn't process multiple (should process number of messages equal to listener concurrency).</p>
  
  <pre><code>&lt;beans:bean id="simpleThreadScope"
      class="org.springframework.context.support.SimpleThreadScope" /&gt;
  
  &lt;util:map id="scopesMap"&gt;
      &lt;beans:entry key="thread" value-ref="simpleThreadScope" /&gt;
  &lt;/util:map&gt;
  
  &lt;beans:bean
      class="org.springframework.beans.factory.config.CustomScopeConfigurer"
      p:scopes-ref="scopesMap" /&gt;
  
  
  
  
  
  &lt;int:channel id="importExchangesChannel" /&gt;
  &lt;int:channel id="importExchangesReplyChannel" scope="thread"&gt;
      &lt;int:queue /&gt;
  &lt;/int:channel&gt;
  
  &lt;beans:bean id="importExchangesMessagingTemplate"
      class="org.springframework.integration.core.MessagingTemplate"
      p:defaultChannel-ref="importExchangesChannel" p:receiveTimeout="${import.exchanges.reply.timeout}" /&gt;
  
  &lt;amqp:outbound-channel-adapter
      amqp-template="amqpTemplate" channel="importExchangesChannel"
      exchange-name="${import.exchanges.exchange}" routing-key="${import.exchanges.routing.key}" /&gt;
  
  &lt;rabbit:listener-container
      connection-factory="rabbitConnectionFactory" concurrency="${import.exchanges.listener.concurrency}"
      requeue-rejected="false" prefetch="1"&gt;
      &lt;rabbit:listener queues="${import.exchanges.queue}"
          ref="importExchangesChunkHandler" method="handleChunk" /&gt;
  &lt;/rabbit:listener-container&gt;
  
  
  &lt;int:channel id="importEclsChannel" /&gt;
  &lt;int:channel id="importEclsReplyChannel" scope="thread"&gt;
      &lt;int:queue /&gt;
  &lt;/int:channel&gt;
  
  &lt;beans:bean id="importEclsMessagingTemplate"
      class="org.springframework.integration.core.MessagingTemplate"
      p:defaultChannel-ref="importEclsChannel" p:receiveTimeout="${import.ecls.reply.timeout}" /&gt;
  
  &lt;amqp:outbound-channel-adapter
      amqp-template="amqpTemplate" channel="importEclsChannel"
      exchange-name="${import.ecls.exchange}" routing-key="${import.ecls.routing.key}" /&gt;
  
  &lt;rabbit:listener-container
      connection-factory="rabbitConnectionFactory" concurrency="${import.ecls.listener.concurrency}"
      requeue-rejected="false" prefetch="1"&gt;
      &lt;rabbit:listener queues="${import.ecls.queue}"
          ref="importEclsChunkHandler" method="handleChunk" /&gt;
  &lt;/rabbit:listener-container&gt;
  
  
  
  &lt;beans:bean id="importExchangesItemWriter"
      class="com.st.batch.foundation.ImportExchangesItemWriter"
      p:symfony-ref="symfony" p:replyTimeout="${import.exchanges.reply.timeout}" /&gt;
  
  
  &lt;beans:bean id="importExchangesChunkItemWriter"
      class="org.springframework.batch.integration.chunk.ChunkMessageChannelItemWriter"
      scope="step" p:messagingOperations-ref="importExchangesMessagingTemplate"
      p:replyChannel-ref="importExchangesReplyChannel"&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="importExchangesChunkHandler"
      class="org.springframework.batch.integration.chunk.RemoteChunkHandlerFactoryBean"
      p:chunkWriter-ref="importExchangesChunkItemWriter" p:step-ref="importExchangesStep"&gt;
  &lt;/beans:bean&gt;
  
  &lt;rabbit:queue name="${import.exchanges.queue}" /&gt;
  &lt;rabbit:queue name="${import.exchanges.reply.queue}" /&gt;
  
  &lt;rabbit:direct-exchange name="${import.exchanges.exchange}"&gt;
      &lt;rabbit:bindings&gt;
          &lt;rabbit:binding queue="${import.exchanges.queue}"
              key="${import.exchanges.routing.key}" /&gt;
      &lt;/rabbit:bindings&gt;
  &lt;/rabbit:direct-exchange&gt;
  </code></pre>
  
  <p>I can see only 1 message in queue at a time. I should sent messages = ${import.exchanges.commit.interval} and all should be picked up by concurrent listeners and processed parallely.</p>