Class MessageChannelItemWriter<T>
java.lang.Object
org.springframework.batch.integration.support.MessageChannelItemWriter<T>
- Type Parameters:
T- the type of items to be written
- All Implemented Interfaces:
ItemWriter<T>
An
ItemWriter implementation that sends items as messages to a message channel
using a MessagingTemplate. This item writer 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
ConstructorsConstructorDescriptionMessageChannelItemWriter(org.springframework.integration.core.MessagingTemplate messagingGateway) Create a newMessageChannelItemWriterinstance.MessageChannelItemWriter(org.springframework.integration.core.MessagingTemplate messagingTemplate, org.springframework.messaging.MessageChannel messageChannel) Create a newMessageChannelItemWriterinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetMessageChannel(org.springframework.messaging.MessageChannel messageChannel) Set the target message channel.voidProcess the supplied data element.
-
Constructor Details
-
MessageChannelItemWriter
public MessageChannelItemWriter(org.springframework.integration.core.MessagingTemplate messagingGateway) Create a newMessageChannelItemWriterinstance. Messages will be sent to the default destination of the providedMessagingTemplatewhich must not be null.- Parameters:
messagingGateway- the messaging template to use for sending messages
-
MessageChannelItemWriter
public MessageChannelItemWriter(org.springframework.integration.core.MessagingTemplate messagingTemplate, org.springframework.messaging.MessageChannel messageChannel) Create a newMessageChannelItemWriterinstance. Messages will be sent to the provided message channel.- Parameters:
messagingTemplate- the messaging template to use for sending messagesmessageChannel- the message channel to send messages to
-
-
Method Details
-
setMessageChannel
public void setMessageChannel(org.springframework.messaging.MessageChannel messageChannel) Set the target message channel.- Parameters:
messageChannel- the message channel to send messages to
-
write
Description copied from interface:ItemWriterProcess the supplied data element. Will not be called with any null items in normal operation.- Specified by:
writein interfaceItemWriter<T>- Parameters:
items- of items to be written. Must not benull.- Throws:
Exception- if there are errors. The framework will catch the exception and convert or rethrow it as appropriate.
-