イテレーターメディエーターを使用して多数の呼び出しを送信し、集約メディエーターを使用して応答を集約する必要があるというユースケースがあります。集計メディエーターが応答の 1 つを完了すると、期待どおりの部分になり、他の応答が本体の末尾に追加されます。
問題を示すために、次のプロキシを作成しました (ロジックを簡単に理解できるように、多くのログ情報を追加しました)。
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="GbTestServiceProxy" transports="https http" startOnLoad="true" trace="disable">
<target endpoint="GbTestServiceEP">
<inSequence>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** inSequence::START **** " />
</log>
<log level="full">
<property name=" **** GbTestServiceProxy **** " value=" **** inSequence::messageIn **** " />
</log>
<enrich>
<source xmlns:gb="http://www.logius.nl/digikoppeling/gb/2010/10" clone="true" xpath="//gb:digikoppeling-external-data-references"/>
<target type="property" property="DIGI-EXT-DATA-REF"/>
</enrich>
<enrich>
<source type="body" clone="true"/>
<target type="property" property="ORIG_BODY"/>
</enrich>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** inSequence::DigikoppelingExternalDataReference **** " />
<property name="DIGI-EXT-DATA-REF" expression="get-property('DIGI-EXT-DATA-REF')" />
</log>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** inSequence::originalSoapBody **** " />
<property name="ORIG_BODY" expression="get-property('ORIG_BODY')" />
</log>
<property name="gb_iterate_cnt" value="0"/>
<property name="gb_aggregate_cnt" value="0"/>
<iterate xmlns:gb="http://www.logius.nl/digikoppeling/gb/2010/10" preservePayload="true" attachPath="//gb:digikoppeling-external-data-references" expression="//gb:digikoppeling-external-data-references/gb:data-reference">
<target>
<sequence>
<xslt key="conf:/xslt/retrieve_gb_data_reference.xslt"/>
<property name="gb_iterate_cnt" expression="number(get-property('gb_iterate_cnt')) + 1"/>
<log level="full">
<property name=" **** GbTestServiceProxy **** " value=" **** inSequence::iterateDataReference **** "/>
<property name="gb_iterate_cnt" expression="get-property('gb_iterate_cnt')"/>
</log>
<send>
<endpoint>
<address uri="http://192.168.56.100:8280/services/GbHandlerStubProxy"/>
</endpoint>
</send>
</sequence>
</target>
</iterate>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** inSequence::START **** " />
</log>
</inSequence>
<outSequence>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::START **** " />
</log>
<log level="full">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::messageIn **** " />
</log>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::checkIterateCount **** "/>
<property name="gb_iterate_cnt" expression="get-property('gb_iterate_cnt')"/>
</log>
<property name="gb_aggregate_cnt" expression="number(get-property('gb_aggregate_cnt'))+1"/>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::checkAggregateCount **** "/>
<property name="gb_aggregate_cnt" expression="get-property('gb_aggregate_cnt')"/>
</log>
<aggregate>
<completeCondition timeout="5000">
<messageCount min="3" max="3"/>
</completeCondition>
<onComplete xmlns:poc="http://minienm.nl/wso2/wus/2.0/testgb/1.0/" expression="//poc:data-reference-local">
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::checkAggregateCount **** "/>
<property name="gb_aggregate_cnt" expression="get-property('gb_aggregate_cnt')"/>
</log>
<log level="full">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::resultAggregate **** " />
</log>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::enrich#1-storeAggregateResult **** "/>
</log>
<enrich>
<source type="body" clone="false"/>
<target type="property" property="RESULT_AGGREGATE"/>
</enrich>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::originalResultAggregate **** " />
<property name="RESULT_AGGREGATE" expression="get-property('RESULT_AGGREGATE')" />
</log>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::enrich#2-replaceAggregateResultWithOriginalBody **** "/>
</log>
<enrich>
<source type="property" clone="false" property="ORIG_BODY"/>
<target type="body"/>
</enrich>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::enrich#3-addHolderForAggregateResultToBody **** "/>
</log>
<enrich>
<source type="inline" clone="false">
<poc:internal-data-references xmlns:poc="http://minienm.nl/wso2/wus/2.0/testgb/1.0/"/>
</source>
<target xmlns:gb="http://www.logius.nl/digikoppeling/gb/2010/10" action="sibling" xpath="//gb:digikoppeling-external-data-references"/>
</enrich>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::enrich#4-addAggregateResultToHolder **** "/>
</log>
<enrich>
<source type="property" clone="false" property="RESULT_AGGREGATE"/>
<target xmlns:poc="http://minienm.nl/wso2/wus/2.0/testgb/1.0/" action="child" xpath="//poc:internal-data-references"/>
</enrich>
<log level="full">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::send **** "/>
</log>
<send />
</onComplete>
</aggregate>
<log level="custom">
<property name=" **** GbTestServiceProxy **** " value=" **** outSequence::END **** " />
</log>
</outSequence>
</target>
<publishWSDL uri="http://192.168.56.100:8280/services/TestGb_WUS_2.0_v1.0?wsdl"/>
</proxy>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="GbHandlerStubProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="custom">
<property name=" **** GbHandlerStubProxy **** " value=" START " />
</log>
<xslt key="conf:/xslt/create_response_stub_gb_handler.xslt">
<property name="localDirectory" value="/this/is/a/local/directory/" />
</xslt>
<header name="To" action="remove" />
<property name="RESPONSE" value="true" scope="default" type="STRING" />
<log level="custom">
<property name=" **** GbHandlerStubProxy **** " value=" END " />
</log>
<send />
</inSequence>
</target>
</proxy>
これはテスト メッセージです。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://minienm.nl/wso2/wus/2.0/testgb/1.0/" xmlns:ns1="http://www.logius.nl/digikoppeling/gb/2010/10">
<soapenv:Header/>
<soapenv:Body>
<ns:aanleverBericht>
<!--Optional:-->
<ns:kenmerk>kenmerk</ns:kenmerk>
<ns:berichtsoort>berichtsoort</ns:berichtsoort>
<!--Optional:-->
<ns:aanleverkenmerk>aanleverkenmerk</ns:aanleverkenmerk>
<!--Optional:-->
<ns:eerderAanleverkenmerk>eerderAanleverkenmerk</ns:eerderAanleverkenmerk>
<ns:identiteitBelanghebbende>
<ns:nummer>nummer</ns:nummer>
<!--Optional:-->
<ns:type>KvK</ns:type>
</ns:identiteitBelanghebbende>
<ns:rolBelanghebbende>rolBelanghebbende</ns:rolBelanghebbende>
<!--Optional:-->
<ns:identiteitOntvanger>
<ns:nummer>nummer</ns:nummer>
<!--Optional:-->
<ns:type>OIN</ns:type>
</ns:identiteitOntvanger>
<!--Optional:-->
<ns:rolOntvanger>rolOntvanger</ns:rolOntvanger>
<ns:berichtInhoud>
<ns:mimeType>mimeType</ns:mimeType>
<ns:bestandsnaam>bestandsnaam</ns:bestandsnaam>
<ns:inhoud>VGhpcyBpcyBhIHRlc3QgYmFzZTY0IGVuY29kZWQgc3RyaW5n</ns:inhoud>
</ns:berichtInhoud>
<!--Optional:-->
<ns:berichtBijlagen>
<!--1 or more repetitions:-->
<ns:bijlage>
<ns:mimeType>mimeType</ns:mimeType>
<ns:bestandsnaam>bestandsnaam</ns:bestandsnaam>
<ns:inhoud>VGhpcyBpcyBhIHRlc3QgYmFzZTY0IGVuY29kZWQgc3RyaW5n</ns:inhoud>
</ns:bijlage>
</ns:berichtBijlagen>
<!--Optional:-->
<ns:autorisatieAdres>autorisatieAdres</ns:autorisatieAdres>
<!--Optional:-->
<ns1:digikoppeling-external-data-references profile="digikoppeling-gb-1.0">
<!--1 or more repetitions:-->
<ns1:data-reference contextId="contextId-1">
<ns1:lifetime>
<!--Optional:-->
<ns1:creationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:creationTime>
<!--Optional:-->
<ns1:expirationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:expirationTime>
</ns1:lifetime>
<ns1:content contentType="contentType">
<ns1:filename>filename</ns1:filename>
<ns1:checksum type="MD5">0123456789abcdef0123456789abcdef</ns1:checksum>
<ns1:size>1000</ns1:size>
</ns1:content>
<ns1:transport>
<ns1:location>
<!--You have a CHOICE of the next 2 items at this level-->
<ns1:senderUrl type="xs:anyURI">>https://any.url/any.name.sender</ns1:senderUrl>
</ns1:location>
</ns1:transport>
</ns1:data-reference>
<ns1:data-reference contextId="contextId-2">
<ns1:lifetime>
<!--Optional:-->
<ns1:creationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:creationTime>
<!--Optional:-->
<ns1:expirationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:expirationTime>
</ns1:lifetime>
<ns1:content contentType="contentType">
<ns1:filename>filename</ns1:filename>
<ns1:checksum type="MD5">0123456789abcdef0123456789abcdef</ns1:checksum>
<ns1:size>1000</ns1:size>
</ns1:content>
<ns1:transport>
<ns1:location>
<!--You have a CHOICE of the next 2 items at this level-->
<ns1:senderUrl type="xs:anyURI">>https://any.url/any.name.sender</ns1:senderUrl>
</ns1:location>
</ns1:transport>
</ns1:data-reference>
<ns1:data-reference contextId="contextId-3">
<ns1:lifetime>
<!--Optional:-->
<ns1:creationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:creationTime>
<!--Optional:-->
<ns1:expirationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:expirationTime>
</ns1:lifetime>
<ns1:content contentType="contentType">
<ns1:filename>filename</ns1:filename>
<ns1:checksum type="MD5">0123456789abcdef0123456789abcdef</ns1:checksum>
<ns1:size>1000</ns1:size>
</ns1:content>
<ns1:transport>
<ns1:location>
<!--You have a CHOICE of the next 2 items at this level-->
<ns1:senderUrl type="xs:anyURI">>https://any.url/any.name.sender</ns1:senderUrl>
</ns1:location>
</ns1:transport>
</ns1:data-reference>
</ns1:digikoppeling-external-data-references>
</ns:aanleverBericht>
</soapenv:Body>
</soapenv:Envelope>
結果は次のとおりです。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:MessageID>urn:uuid:63df7b91-b96b-4894-9f02-dd00145e4493</wsa:MessageID>
<wsa:Action>//www.minienm.nl/TestGb_WUS_2.0_v1.0/TestGb_WUS_2.0_v1.0/submitDocumentResponse</wsa:Action>
<wsa:RelatesTo>urn:uuid:4ab77dc5-96ac-41d7-8e74-0b444a6cf7e5</wsa:RelatesTo>
</soapenv:Header>
<soapenv:Body>
<ns:aanleverBericht xmlns:ns="http://minienm.nl/wso2/wus/2.0/testgb/1.0/">
<!--Optional:-->
<ns:kenmerk>kenmerk</ns:kenmerk>
<ns:berichtsoort>berichtsoort</ns:berichtsoort>
<!--Optional:-->
<ns:aanleverkenmerk>aanleverkenmerk</ns:aanleverkenmerk>
<!--Optional:-->
<ns:eerderAanleverkenmerk>eerderAanleverkenmerk</ns:eerderAanleverkenmerk>
<ns:identiteitBelanghebbende>
<ns:nummer>nummer</ns:nummer>
<!--Optional:-->
<ns:type>KvK</ns:type>
</ns:identiteitBelanghebbende>
<ns:rolBelanghebbende>rolBelanghebbende</ns:rolBelanghebbende>
<!--Optional:-->
<ns:identiteitOntvanger>
<ns:nummer>nummer</ns:nummer>
<!--Optional:-->
<ns:type>OIN</ns:type>
</ns:identiteitOntvanger>
<!--Optional:-->
<ns:rolOntvanger>rolOntvanger</ns:rolOntvanger>
<ns:berichtInhoud>
<ns:mimeType>mimeType</ns:mimeType>
<ns:bestandsnaam>bestandsnaam</ns:bestandsnaam>
<ns:inhoud>VGhpcyBpcyBhIHRlc3QgYmFzZTY0IGVuY29kZWQgc3RyaW5n</ns:inhoud>
</ns:berichtInhoud>
<!--Optional:-->
<ns:berichtBijlagen>
<!--1 or more repetitions:-->
<ns:bijlage>
<ns:mimeType>mimeType</ns:mimeType>
<ns:bestandsnaam>bestandsnaam</ns:bestandsnaam>
<ns:inhoud>VGhpcyBpcyBhIHRlc3QgYmFzZTY0IGVuY29kZWQgc3RyaW5n</ns:inhoud>
</ns:bijlage>
</ns:berichtBijlagen>
<!--Optional:-->
<ns:autorisatieAdres>autorisatieAdres</ns:autorisatieAdres>
<!--Optional:-->
<ns1:digikoppeling-external-data-references profile="digikoppeling-gb-1.0" xmlns:ns1="http://www.logius.nl/digikoppeling/gb/2010/10">
<!--1 or more repetitions:-->
<ns1:data-reference contextId="contextId-1">
<ns1:lifetime>
<!--Optional:-->
<ns1:creationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:creationTime>
<!--Optional:-->
<ns1:expirationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:expirationTime>
</ns1:lifetime>
<ns1:content contentType="contentType">
<ns1:filename>filename</ns1:filename>
<ns1:checksum type="MD5">0123456789abcdef0123456789abcdef</ns1:checksum>
<ns1:size>1000</ns1:size>
</ns1:content>
<ns1:transport>
<ns1:location>
<!--You have a CHOICE of the next 2 items at this level-->
<ns1:senderUrl type="xs:anyURI">>https://any.url/any.name.sender</ns1:senderUrl>
</ns1:location>
</ns1:transport>
</ns1:data-reference>
<ns1:data-reference contextId="contextId-2">
<ns1:lifetime>
<!--Optional:-->
<ns1:creationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:creationTime>
<!--Optional:-->
<ns1:expirationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:expirationTime>
</ns1:lifetime>
<ns1:content contentType="contentType">
<ns1:filename>filename</ns1:filename>
<ns1:checksum type="MD5">0123456789abcdef0123456789abcdef</ns1:checksum>
<ns1:size>1000</ns1:size>
</ns1:content>
<ns1:transport>
<ns1:location>
<!--You have a CHOICE of the next 2 items at this level-->
<ns1:senderUrl type="xs:anyURI">>https://any.url/any.name.sender</ns1:senderUrl>
</ns1:location>
</ns1:transport>
</ns1:data-reference>
<ns1:data-reference contextId="contextId-3">
<ns1:lifetime>
<!--Optional:-->
<ns1:creationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:creationTime>
<!--Optional:-->
<ns1:expirationTime type="xs:dateTime">2001-12-31T12:00:00Z</ns1:expirationTime>
</ns1:lifetime>
<ns1:content contentType="contentType">
<ns1:filename>filename</ns1:filename>
<ns1:checksum type="MD5">0123456789abcdef0123456789abcdef</ns1:checksum>
<ns1:size>1000</ns1:size>
</ns1:content>
<ns1:transport>
<ns1:location>
<!--You have a CHOICE of the next 2 items at this level-->
<ns1:senderUrl type="xs:anyURI">>https://any.url/any.name.sender</ns1:senderUrl>
</ns1:location>
</ns1:transport>
</ns1:data-reference>
</ns1:digikoppeling-external-data-references>
<poc:internal-data-references xmlns:poc="http://minienm.nl/wso2/wus/2.0/testgb/1.0/">
<poc:data-reference-local contextId="contextId-1" xmlns:gb="http://www.logius.nl/digikoppeling/gb/2010/10">
<poc:location>/this/is/a/local/directory/filename</poc:location>
</poc:data-reference-local>
</poc:internal-data-references>
</ns:aanleverBericht>
<poc:data-reference-local contextId="contextId-2" xmlns:poc="http://minienm.nl/wso2/wus/2.0/testgb/1.0/" xmlns:gb="http://www.logius.nl/digikoppeling/gb/2010/10">
<poc:location>/this/is/a/local/directory/filename</poc:location>
</poc:data-reference-local>
<poc:data-reference-local contextId="contextId-3" xmlns:poc="http://minienm.nl/wso2/wus/2.0/testgb/1.0/" xmlns:gb="http://www.logius.nl/digikoppeling/gb/2010/10">
<poc:location>/this/is/a/local/directory/filename</poc:location>
</poc:data-reference-local>
</soapenv:Body>
</soapenv:Envelope>
ご覧のとおり、最後の 2 つの poc:data-reference-local エントリが本文の末尾に追加されています。私が間違っていることは何ですか?
もう 1 つの奇妙な点は、集約メディエーター (outSequence::resultAggregate) の 2 番目のログ エントリが、3 つの結果すべてを期待どおりに示していることです。ただし、ログ エントリ originalResultAggregate には最初の 1 つしか表示されません。これは、私が経験している奇妙な動作と関係がありますか?
編集: 私が気付いたもう 1 つのことは、追加したカウンター機能が機能しないことです (プロパティ gb_iterate_cnt & gb_aggregate_cnt を参照)。私は何を間違っていますか?
よろしく、ニドキル