3

リクエストのリストを 1 つのペイロードで送信し、そのペイロードをいくつかの xpath に基づいて個々のリクエストに分割し、個々の http アウトバウンド コールを作成し、バックでそれらを集約するシナリオを試みています。プロセス全体は正常に動作しますが、分割されたメッセージ ペイロードから抽出された値を使用して呼び出しプロパティを追加しようとしましたが、すべての分割されたメッセージの値が常に表示されています。これが私が持っているラバフロー構成です:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd">
    <!-- HTTPS Connection Configuration With CERTS -->
    <https:connector name="HTTP_HTTPS" cookieSpec="netscape" validateConnections="true" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0" clientSoTimeout="10000" serverSoTimeout="10000" socketSoLinger="0" doc:name="HTTP-HTTPS">
        <https:tls-server  path="/Users/rkesara/opt/MULE/truststore/cacerts" storePassword="changeit" />
    </https:connector>

    <!-- List of transformers that might be useful for this flow -->
    <mulexml:dom-to-xml-transformer outputEncoding="UTF-8" name="DOM_to_XML" doc:name="DOM to XML"/>

    <!-- Root flow that can trigger pull and push functionality -->
    <flow name="PushInventoryFlow" doc:name="PushInventoryFlow">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
        <logger message="PushInventoryFlow - Listing requests payload : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>

        <logger message="PullAndPushInventoryFlow - Splitting listing requests..." level="INFO" doc:name="Logger"/>
        <splitter enableCorrelation="ALWAYS" expression="#[xpath('//listings/listing')]" doc:name="ListingRequestSplitter"/>
        <logger message="PullAndPushInventoryFlow - Number of listing requests found after bunlding : #[header:MULE_CORRELATION_GROUP_SIZE] - current request number : #[header:MULE_CORRELATION_SEQUENCE]" level="INFO" doc:name="Logger"/>

        <flow-ref name="ListingMessageProcessorFlow" />

        <collection-aggregator />        
        <logger message="Aggregated Payload-&gt; #[payload]" level="INFO" doc:name="Logger"/>
   </flow>

   <flow name="ListingMessageProcessorFlow" doc:name="ListingMessageProcessorFlow">

        <message-properties-transformer scope="invocation" doc:name="Remember correlation">
            <add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_ID]" key="cid" />
            <add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_GROUP_SIZE]" key="cgs" />

            <add-message-property value="#[xpath://listing/section]" key="section" />
        </message-properties-transformer>

        <logger message="ListingMessageProcessorFlow - Invoking listingAPI for Section: #[header:INVOCATION:section] with request payload : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
        <https:outbound-endpoint exchange-pattern="request-response" host="api-dev.srwd10.com" port="443" path="inventory/listings/v1/" method="POST" doc:name="HTTP" connector-ref="HTTP_HTTPS" transformer-refs="DOM_to_XML" contentType="application/xml" mimeType="application/xml">
            <message-properties-transformer scope="outbound">
                <add-message-property key="Authorization" value="Bearer blahblahblah" />
                <add-message-property key="TARGET_HOST" value="srwq12" />
                <add-message-property key="Acccept" value="application/xml" />
            </message-properties-transformer>
        </https:outbound-endpoint>
        <logger message="ListingMessageProcessorFlow - Listing API response : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>

        <message-properties-transformer scope="outbound">
            <add-message-property value="#[header:INVOCATION:cid]" key="MULE_CORRELATION_ID" />
            <add-message-property value="#[header:INVOCATION:cgs]" key="MULE_CORRELATION_GROUP_SIZE" />
        </message-properties-transformer>

    </flow>

</mule>

リクエスト xml に従います。

<listings>
   <listing>
      <eventId>4457573</eventId>
      <eventDescription>The Book of Mormon Houston</eventDescription>
      <pricePerTicket>
         <amount>900</amount>
         <currency>USD</currency>
      </pricePerTicket>
      <quantity>1</quantity>
      <section>CENTER ORCHESTRA</section>
      <rows>M</rows>
      <seats>2</seats>
      <splitOption>NONE</splitOption>
   </listing>
   <listing>
      <eventId>4457573</eventId>
      <eventDescription>The Book of Mormon Houston</eventDescription>
      <pricePerTicket>
         <amount>902</amount>
         <currency>USD</currency>
      </pricePerTicket>
      <quantity>1</quantity>
      <section>CENTER ORCHESTRA</section>
      <rows>M</rows>
      <seats>1</seats>
      <splitOption>NONE</splitOption>
   </listing>
   <listing>
      <eventId>4457573</eventId>
      <eventDescription>The Book of Mormon Houston</eventDescription>
      <pricePerTicket>
         <amount>905</amount>
         <currency>USD</currency>
      </pricePerTicket>
      <quantity>2</quantity>
      <section>CENTER ORCHESTRA</section>
      <rows>M</rows>
      <seats>4,6</seats>
      <splitOption>NONE</splitOption>
   </listing>
   <listing>
      <eventId>4457573</eventId>
      <eventDescription>The Book of Mormon Houston</eventDescription>
      <pricePerTicket>
         <amount>906</amount>
         <currency>USD</currency>
      </pricePerTicket>
      <quantity>1</quantity>
      <section>CENTER ORCHESTRA</section>
      <rows>M</rows>
      <seats>5</seats>
      <splitOption>NONE</splitOption>
   </listing>
   <listing>
      <eventId>4457573</eventId>
      <eventDescription>The Book of Mormon Houston</eventDescription>
      <pricePerTicket>
         <amount>907</amount>
         <currency>USD</currency>
      </pricePerTicket>
      <quantity>2</quantity>
      <section>CENTER ORCHESTRA</section>
      <rows>M</rows>
      <seats>7,9</seats>
      <splitOption>NONE</splitOption>
   </listing>
   <listing>
      <eventId>4457573</eventId>
      <eventDescription>The Book of Mormon Houston</eventDescription>
      <pricePerTicket>
         <amount>908</amount>
         <currency>USD</currency>
      </pricePerTicket>
      <quantity>2</quantity>
      <section>CENTER ORCHESTRA</section>
      <rows>M</rows>
      <seats>3,8</seats>
      <splitOption>NONE</splitOption>
   </listing>
   <listing>
      <eventId>4457573</eventId>
      <eventDescription>The Book of Mormon Houston</eventDescription>
      <pricePerTicket>
         <amount>909</amount>
         <currency>USD</currency>
      </pricePerTicket>
      <quantity>1</quantity>
      <section>CENTER ORCHESTRA</section>
      <rows>M</rows>
      <seats>10</seats>
      <splitOption>NONE</splitOption>
   </listing>
</listings>

ログに表示される動作は次のとおりです。

INFO  2014-06-25 11:29:07,860 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: PushInventoryFlow - Number of listing requests found after bunlding : 7 - current request number : 1
INFO  2014-06-25 11:29:07,862 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: ListingMessageProcessorFlow - Invoking listingAPI for Section: [CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA] with request payload : <listing><eventId>4457573</eventId><eventDescription>The Book of Mormon Houston</eventDescription><pricePerTicket><amount>900</amount><currency>USD</currency></pricePerTicket><quantity>1</quantity><section>CENTER ORCHESTRA</section><rows>M</rows><seats>2</seats><splitOption>NONE</splitOption></listing>
INFO  2014-06-25 11:29:12,200 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: ListingMessageProcessorFlow - Listing API response Payload: {"listing":{"id":"1082835915","status":"ACTIVE"}}
INFO  2014-06-25 11:29:12,201 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: PushInventoryFlow - Number of listing requests found after bunlding : 7 - current request number : 2
INFO  2014-06-25 11:29:12,202 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: ListingMessageProcessorFlow - Invoking listingAPI for Section: [CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA] with request payload : <listing><eventId>4457573</eventId><eventDescription>The Book of Mormon Houston</eventDescription><pricePerTicket><amount>902</amount><currency>USD</currency></pricePerTicket><quantity>1</quantity><section>CENTER ORCHESTRA</section><rows>M</rows><seats>1</seats><splitOption>NONE</splitOption></listing>
INFO  2014-06-25 11:29:12,695 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: ListingMessageProcessorFlow - Listing API response Payload: {"listing":{"id":"1082835916","status":"ACTIVE"}}
INFO  2014-06-25 11:29:12,695 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: PushInventoryFlow - Number of listing requests found after bunlding : 7 - current request number : 3
INFO  2014-06-25 11:29:12,697 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: ListingMessageProcessorFlow - Invoking listingAPI for Section: [CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA] with request payload : <listing><eventId>4457573</eventId><eventDescription>The Book of Mormon Houston</eventDescription><pricePerTicket><amount>905</amount><currency>USD</currency></pricePerTicket><quantity>2</quantity><section>CENTER ORCHESTRA</section><rows>M</rows><seats>4,6</seats><splitOption>NONE</splitOption></listing>

誰かが問題を指摘するのを手伝ってくれますか。参考までに、その xpath 値の set-variable に関する別の問題に直面しています。この時点で、個々の分割されたメッセージが持つ値を呼び出しごとに維持することを確認したかったのですが、ここではすべての分割されたメッセージの値を取得します。

私の問題はこの値にあります-もっと説明するだけです

ListingMessageProcessorFlow - Invoking listingAPI for Section:

[CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA, CENTER ORCHESTRA]

リクエストペイロード付き:

<listing><eventId>4457573</eventId><eventDescription>The Book of Mormon Houston</eventDescription><pricePerTicket><amount>900</amount><currency>USD</cur‌​rency></pricePerTicket><quantity>1</quantity><section>CENTER ORCHESTRA</section><rows>M</rows><seats>2</seats><splitOption>NONE</splitOption>‌​&lt;/listing>
4

1 に答える 1

0

Anypoint 3.5 または 3.6 でこれを改善するためにできることがいくつかあるようです。

  1. スプリッター式のxpath('<expression>', payload)代わりに使用します。xpath('<expression>')スプリッターは、ペイロードをチャンクに分割するという点で引き続き正常に機能しますが、子フローの xpath 呼び出しは、例のように元のペイロード全体ではなく、元のペイロードの現在のチャンクに対して機能します。これは @Ryan Carter のコメントで言及されており、Anypoint Studio 3.5.2 にも引き続き適用されます。
  2. @David Dossotが言及したように、設定しているアイテムに対応する現在のバージョンの適切なセッターコンポーネントを使用してください。フロー変数の設定は、<set-variable>現在行っていることに対応しています。
    • <set-property>アウトバウンド プロパティの設定用
    • <set-variable>フロー変数の設定用
    • <set-session-variable>セッション変数の設定用
  3. <foreach>スプリッター アグリゲーター パターンの代わりにスコープを使用します。XML を使用したスプリッター アグリゲーターの欠点は、呼び出し元に送り返す前に単一のオブジェクトにマージする必要がある DOM オブジェクトのコレクションを取得することです。foreach を使用する場合、foreach は元のペイロードへの参照を使用するため、コレクション内の既存のオブジェクトを変更できます。
    • foreach で XPath を使用する方法
    • foreach コレクションの現在の項目のコンテンツを置き換える必要がある場合rootMessage.payload[counter-1] = payload;は、右側のペイロードが現在の for-each 反復のペイロードであり、その反復でのみ有効であり、rootMessage.payload がコレクション全体。これが foreach と DOM ペイロードおよび XPath コレクションでどのように機能するかを試してみることができます。
于 2015-02-16T05:39:57.020 に答える