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 Summary
ConstructorsConstructorDescriptionMessageChannelItemReader(org.springframework.integration.core.MessagingTemplate messagingTemplate, Class<T> targetType) Create a newMessageChannelItemReaderinstance.MessageChannelItemReader(org.springframework.integration.core.MessagingTemplate messagingTemplate, org.springframework.messaging.MessageChannel messageChannel, Class<T> targetType) Create a newMessageChannelItemReaderinstance. -
Method Summary
Modifier and TypeMethodDescription@Nullable Tread()voidsetMessageChannel(org.springframework.messaging.MessageChannel messageChannel) Set the source message channel.
-
Constructor Details
-
MessageChannelItemReader
public MessageChannelItemReader(org.springframework.integration.core.MessagingTemplate messagingTemplate, Class<T> targetType) Create a newMessageChannelItemReaderinstance. Messages will be read from the default destination of the providedMessagingTemplatewhich must not be null.- Parameters:
messagingTemplate- the messaging template to use for reading messagestargetType- 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 newMessageChannelItemReaderinstance. Messages will be read from the provided target message channel.- Parameters:
messagingTemplate- the messaging template to use for receiving messagesmessageChannel- the message channel to read messages fromtargetType- 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
-