Class MessageChannelItemReader<T>

java.lang.Object
org.springframework.batch.integration.support.MessageChannelItemReader<T>
Type Parameters:
T - the type of items to be read
All Implemented Interfaces:
org.springframework.batch.infrastructure.item.ItemReader<T>

public class MessageChannelItemReader<T> extends Object implements org.springframework.batch.infrastructure.item.ItemReader<T>
An ItemReader implementation that receives items as messages from a message channel using a MessagingTemplate. This item reader enables SEDA (Staged Event-Driven Architecture) patterns in Spring Batch jobs by decoupling item production from item consumption through messaging.
Since:
6.0.0
Author:
Mahmoud Ben Hassine
  • Constructor Details

    • MessageChannelItemReader

      public MessageChannelItemReader(org.springframework.integration.core.MessagingTemplate messagingTemplate, Class<T> targetType)
      Create a new MessageChannelItemReader instance. Messages will be read from the default destination of the provided MessagingTemplate which must not be null.
      Parameters:
      messagingTemplate - the messaging template to use for reading messages
      targetType - the target type of items to convert messages to
    • MessageChannelItemReader

      public MessageChannelItemReader(org.springframework.integration.core.MessagingTemplate messagingTemplate, org.springframework.messaging.MessageChannel messageChannel, Class<T> targetType)
      Create a new MessageChannelItemReader instance. Messages will be read from the provided target message channel.
      Parameters:
      messagingTemplate - the messaging template to use for receiving messages
      messageChannel - the message channel to read messages from
      targetType - the target type of items to convert messages to
  • Method Details

    • setMessageChannel

      public void setMessageChannel(org.springframework.messaging.MessageChannel messageChannel)
      Set the source message channel.
      Parameters:
      messageChannel - the message channel to read messages from
    • read

      public @Nullable T read() throws Exception
      Specified by:
      read in interface org.springframework.batch.infrastructure.item.ItemReader<T>
      Throws:
      Exception