このコンテンツは選択した言語では利用できません。

A.12. XPath Splitter


Overview

A splitter, shown in Figure A.8, “XPath Splitter Pattern”, 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 ServiceMix 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 XPath splitter pattern maps to the splitter pattern in Apache Camel.

Figure A.8. XPath Splitter Pattern

XPath splitter pattern

Forwarding NMR attachments and properties

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. The corresponding splitter pattern in Apache Camel does not support any such attributes. By default, the incoming message's headers are copied to each of the outgoing messages by the Apache Camel splitter.

Example ServiceMix EIP route

Example A.25, “ServiceMix EIP XPath Splitter” shows how to define a splitter using the ServiceMix EIP component. The specified XPath expression, /*/*, causes an incoming message to split at every occurrence of a nested XML element (for example, the /foo/bar and /foo/car elements are split into distinct messages).

Example A.25. ServiceMix EIP XPath Splitter

<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>

Equivalent Apache Camel XML route

Example A.26, “Apache Camel XPath Splitter Using XML” shows how to define an equivalent route using Apache Camel XML configuration.

Example A.26. Apache Camel XPath Splitter Using XML

<route>
  <from uri="jbi:endpoint:http://progress.com/demos/test/xpathSplitter/endpoint"/>
  <splitter>
    <xpath>/*/*</xpath>
    <to uri="jbi:service:http://test/router"/>
  </splitter>
</route>

Equivalent Apache Camel Java DSL route

Example A.27, “Apache Camel XPath Splitter Using Java DSL” shows how to define an equivalent route using the Apache Camel Java DSL.

Example A.27. Apache Camel XPath Splitter Using Java DSL

from("jbi:endpoint:http://progress.com/demos/test/xpathSplitter/endpoint").
    splitter(xpath("/*/*")).to("jbi:service:http://test/router");
Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.