-
Notifications
You must be signed in to change notification settings - Fork 33
Message splitter
EIP reference for Message Splitter can be found here - http://www.eaipatterns.com/Sequencer.html
Continuation from Message Splitter could be expressed using '-->' operator.
val splitter = splitter.using { m: Message[_] => m.getPayoad}
At first it might appear is that splitter is no different than the Service Activator. The only differentce is the signature of the Function that it takes as an input parameter which is **Function1[,Iterable[Any]]**_ You can clearly see an example of how Splitter works in the Order Processing sample
case class PurchaseOrder(val items: List[PurchaseOrderItem])
val validOrder = PurchaseOrder(List(
PurchaseOrderItem("books", "Spring Integration in Action"),
PurchaseOrderItem("books", "DSLs in Action"),
PurchaseOrderItem("bikes", "Canyon Torque FRX")))
...
val orderProcessingFlow =
filter.using{p:PurchaseOrder => !p.items.isEmpty}.where(exceptionOnRejection = true) -->
split.using{p:PurchaseOrder => p.items} --> . . .
If you need to add any extra properties to the Message Splitter you may do so using where method which accepts named parameters.
For example:
val simpleSplitterA = split.using { m: Message[_] => m } where(name="mySplitter") //infix
val simpleSplitterB = split.using { m: Message[_] => m }.where(name="mySplitter")
will produce a Message Splitter named 'mySplitter'.
name - component name
[Back to Core Messaging Patterns] (https://github.com/SpringSource/spring-integration-scala/wiki/Core-Messaging-Patterns)