Question

I am trying to implement remote chunking in spring batch using spring integration and amqp (rabbitmq).

I am not able to understand how does ChunkMessageChannelItemWriter collect replies in remote chunking test below

https://github.com/spring-projects/spring-batch/blob/master/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkStepIntegrationTests-context.xml

How does it work ? Does it send one message, wait for its reply, receives its reply and Then again second message, wait for second message reply and receives second message reply and so on ?

Or it sends all messages asynchronously and wait for replies and then receives replies as they arrives on reply channel ?

If we refer to remote chunking documentation here

http://docs.spring.io/spring-batch/reference/html/springBatchIntegration.html#asynchronous-processors

it uses inbound and outbound adapters. If ChunkMessageChannelItemWriter receives replies why do we need adapters ? and at slave side why adapters and service activator both are used?

Can anybody please help me to understand how it works as its difficult to understand from documentation.

Was it helpful?

Solution

That is just a test case - everything runs locally - look at the JMS test case for a more real-world example. The channel item writer sends all the chunks to JMS using an outbound channel adapter.

The remote side (jms listener container) receives the chunks, processes them and sends the replies to the replies queue.

Each time the writer is called to write a chunk, it checks for replies and suspends, if necessary, if the throttle limit is exceeded.

When all chunks are written, in afterStep(), it waits for the rest of the results.

This all works the same with the local test case because the chunk handler writes the replies to a queue channel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top