Announcement Announcement Module
Collapse
No announcement yet.
Spring Batch ItemReader for int:channel Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Batch ItemReader for int:channel

    Hi,
    I'm trying to integrate spring-integration and spring-batch to persist network messages. These messages will be held up in a queue-channel and want to periodically poll (flush) from channel through ItemReader.

    My question is: how do I make item reader poll from a channel/aggregate them and delegate to writer to persist. I tried to search around, and my stumbling block happens to Item(Channel)Reader.

    Thank you for helping me.

    thanks

  • #2
    Your ItemReader should read messages off the channel one at a time as any other ItemReader would. It is the chunk size that would indicate when the write is called. I'm assuming you are using a custom ItemReader. If you can post your code here, we can take a look.

    Comment


    • #3
      Thank you.
      I implemented a solution. I had to use int:outbound-channel-adapter to pull message off channel and hold it in a Queue. Later, invoking spring-batch job through quartz, reader pulls off messages from Queue. Subsequent operations (processor, and writer) are provided out of box and worked pretty well.

      For those who are in a similar situation:
      <int:aggregator ref="aggregatorRef"
      correlation-strategy-expression="expression"
      release-strategy="beanRef" message-store="simpleMessageStore"
      input-channel="inputChannel"
      output-channel="outputChannel"
      send-partial-result-on-expiry="true" />

      <int:outbound-channel-adapter channel="outputChannel" ref="messageAggregator" method="add"/>

      <batch:job id="jobImpl">
      <batch:step id="step">
      <batch:tasklet allow-start-if-complete="true">
      <batch:chunk reader="messageAggregator" processor="processor-ref"
      writer="persister" commit-interval="10"/>
      </batch:tasklet>
      </batch:step>
      </batch:job>

      Observe that messageAggregator in reader and outbound-channel-adatper are referring to the same bean.

      Thanks again.

      Comment


      • #4
        hi,

        could you please post the source code for the messageAggregator bean?

        thanks

        Comment

        Working...
        X