liveBook · Manning

Splitter

As explained in Spring in Action, Sixth Edition

@Splitter is a Spring Integration annotation that identifies a method as producing multiple messages from an input message.

A splitter is a Spring Integration component that turns one incoming message into multiple messages. Each resulting message can continue independently through different channels or subflows. section 10.2 section 10.2.5

Use a splitter when a payload contains a collection whose items need individual processing, or when related data belongs in different processing paths. A router can follow the splitter when the resulting payloads have different types. section 10.2.5

Splitting a purchase order

An OrderSplitter can extract billing information and line items from a purchase order, return them in a collection, and publish each element as a separate message. Annotate its bean with @Splitter(inputChannel="poChannel", outputChannel="splitOrderChannel") to connect the operation to the flow. A PayloadTypeRouter can then send BillingInfo and line-item messages to their respective channels. section 10.2.5

A second splitter can divide the line-item collection so each LineItem receives individual handling. The same flow can also use Java DSL operations such as split(), route(), subFlowMapping(), and handle() to express the split and its subflows.

How Spring in Action, Sixth Edition covers it

How deep it goes
Defines splitting, demonstrates POJO extraction and annotation wiring, and shows Java DSL alternatives without detailing framework internals.
Examples
Uses purchase orders, billing information, line items, OrderSplitter, @Splitter, PayloadTypeRouter, and Java DSL flows.
What it assumes
Assumes basic familiarity with Spring Integration messages, channels, and integration flows while defining their roles briefly.
What you can do after
Build it from scratch by returning payload parts from a POJO and wiring the bean with @Splitter or Java DSL split operations.
How it connects
Connects splitters with messages, channels, routers, subflows, and aggregators.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.