Skip to content
This repository was archived by the owner on Jul 9, 2022. It is now read-only.

Message splitter

olegz edited this page Jun 5, 2012 · 10 revisions

EIP reference for Message Splitter can be found here - http://www.eaipatterns.com/Sequencer.html

Continuation from Message Splitter could be expressed using '-->' operator.

Message Splitter

Root DSL element for Message Splitter is split

val splitter = splitter { 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{p:PurchaseOrder => !p.items.isEmpty}.where(exceptionOnRejection = true) -->
      split{p:PurchaseOrder => p.items} --> . . .

If you need to add any extra properties to the Message Splitter you may do so using additionalAttributes method which accepts named parameters.

For example:

val simpleSplitterA = split { m: Message[_] => m } additionalAttributes(name="mySplitter") //infix

val simpleSplitterB = split { m: Message[_] => m }.additionalAttributes(name="mySplitter") 

will produce a Message Splitter named 'mySplitter'.

Properties that could be set:

name - component name


[Back to Core Messaging Patterns] (https://github.com/SpringSource/spring-integration-dsl-scala/wiki/Core-Messaging-Patterns)