A splitter is a type of router that splits an incoming message into a series of outgoing messages, where each of the messages contains a piece of the original message. The EIP XPath splitter pattern is restricted to using the InOnly and RobustInOnly exchange patterns. The expression that defines how to split up the original message is defined in the XPath language.
The eip:xpath-splitter element supports a forwardAttachments
attribute and a forwardProperties attribute, either of which can be set to
true, if you want the splitter to copy the incoming message's attachments or
properties to the outgoing messages.
For each outgoing message, the XPath splitter sets the following properties:
The total number of parts into which the original message was split.
The index of the current partial message (starting from 0).
A correlation ID that relates outgoing messages to the original message: the correlation ID is the same for all message generated from the same incoming message.
The following example shows how to define a splitter using the EIP service engine. The
specified XPath expression, /*/*, would cause an incoming message to split at
every occurrence of a nested XML element (for example, the /foo/bar and
/foo/car elements would be split into distinct messages).
<eip:xpath-splitter service="test:xpathSplitter" endpoint="endpoint"
xpath="/*/*" namespaceContext="#nsContext">
<eip:target>
<eip:exchange-target uri="service:http://test/router" />
</eip:target>
</eip:xpath-splitter>The following table lists attributes of <eip:xpath-splitter>:
Table 2.26. Attributes for XPath Splitter
| Attribute | Type | Description |
|---|---|---|
endpoint
|
xs:string
| Name of the endpoint. |
forwardAttachments
|
xs:boolean
| Indicates whether incoming attachments are forwarded with the new exchanges. |
forwardProperties
|
xs:boolean
| Indicates whether properties on the incoming message are forwarded. |
interfaceName
|
xs:QName
| QName of the interface exposed by the endpoint. |
reportErrors
|
xs:boolean
| Indicates whether faults and errors from split parts are sent back to the consumer. In such a case, only the first fault or error received is reported. Note that if the consumer is synchronous, it is blocked until all parts have been successfully acked, or a fault or error is reported, and the exchange is kept in the store for recovery. |
service
|
xs:QName
| QName of the service exposed by the endpoint. |
synchronous
|
xs:boolean
| Specifies whether exchanges for all parts are sent synchronously. |
wsdlResource
|
xs:string
| Spring resource used to load WSDL describing this endpoint (takes precedence over wsdlExchangeTarget). |
xpath
|
xs:string
| XPath expression used to split the input message. |
The following table lists elements of <eip:xpath-splitter>:
Table 2.27. Elements for XPath Splitter
| Element | Type | Description |
|---|---|---|
factory
|
spring:bean
| XPath factory. If you do not specify one, a default factory is created using
XPathFactory.newInstance(). |
functionResolver
|
spring:bean
| Function resolver. |
lockManager
|
spring:bean
| Lock manager to use for this endpoint. If you do not specify one, a default implementation is provided. |
namespaceContext
| namespace-context | Namespace context to use when evaluating the xpath expression. |
store
|
spring:bean
| Store to use. If you do not specify one, the active storeFactory creates one. |
storeFactory
|
spring:bean
| Store factory used to create a store. If you do not specify one, a default factory is used, which creates in-memory only stores. |
target
|
exchange-target
| JBI endpoint receiving the exchange. |
timerManager
|
spring:bean
| Timer manager to use for this endpoint. If you do not specify one, a default implementation is used. |
variableResolver
|
spring:bean
| Variable resolver: the default one enables the use of properties on the message and exchange; it also makes system properties and environment properties available. |
wsdlExchangeTarget
|
exchange-target
| JBI endpoint acting as a WSDL proxy for this endpoint, enabling you to reuse WSDL across multiple endpoints. |