How does ChunkMessageChannelItemWriter collect replies in spring batch remote chunking?

五迷三道 提交于 2019-12-11 21:17:33

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/24033484/how-does-chunkmessagechannelitemwriter-collect-replies-in-spring-batch-remote-ch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!