WSO2 聚合中介 premature/incomplete/unknown 完成

WSO2 Aggregate Mediator premature/incomplete/unknown completion

我的聚合调解器在代理的输出序列中遇到了一个令人困惑的问题。

配置:

实现迭代中介的序列迭代了以下消息:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <productSearchRs xmlns="SHC">
            <productDetails>
                <Product_ID>1487326</Product_ID>
                <Product_Name>SECRET</Product_Name>
                <Product_Size>M</Product_Size>
                <Product_Colour>BLACK</Product_Colour>
                <Product_Type>SOCKS</Product_Type>
                <Source>SHC</Source>
            </productDetails>
            <productDetails>
                <Product_ID>1985211</Product_ID>
                <Product_Name>SECRET</Product_Name>
                <Product_Size>M</Product_Size>
                <Product_Colour>BLACK</Product_Colour>
                <Product_Type>SOCKS</Product_Type>
                <Source>SHC</Source>
            </productDetails>
        </productSearchRs>
    </soapenv:Body>
</soapenv:Envelope>

进入这些(在 payloadFactory 之后):

<pfPadding>
    <productDetails>
        <productID>1487326</productID>
        <productName>SECRET</productName>
        <productSize>M</productSize>
        <productColour>BLACK</productColour>
        <productType>SOCKS</productType>
        <sourceID>SHC</sourceID>
    </productDetails>
</pfPadding> 

<pfPadding>
    <productDetails>
        <productID>1985211</productID>
        <productName>SECRET</productName>
        <productSize>M</productSize>
        <productColour>BLACK</productColour>
        <productType>SOCKS</productType>
        <sourceID>SHC</sourceID>
    </productDetails>
</pfPadding>

完整序列:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="shcServiceSearchSeqRs">
    <log level="custom">
      <property name="Below response recieved from Shc-DS" value="=================="></property>
   </log>
   <log level="full"></log>
   <log level="custom">
      <property name="Splitting product_Detail/s up" value="=================="></property>
   </log>
   <property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd" name="Product_ID" expression="//ns1:productDetails/ns1:Product_ID/text()" scope="default" type="STRING"></property>
   <filter xmlns:ns="http://org.apache.synapse/xsd" xpath="boolean(get-property('Product_ID'))">
      <then>
         <iterate xmlns:ns1="SHC" expression="//ns1:productDetails">
            <target>
               <sequence>
                  <property name="Product_ID" expression="//ns1:productDetails/ns1:Product_ID/text()" scope="default" type="STRING"></property>
                  <property name="Product_Name" expression="//ns1:productDetails/ns1:Product_Name/text()" scope="default" type="STRING"></property>
                  <property name="Product_Size" expression="//ns1:productDetails/ns1:Product_Size/text()" scope="default" type="STRING"></property>
                  <property name="Product_Colour" expression="//ns1:productDetails/ns1:Product_Colour/text()" scope="default" type="STRING"></property>
                  <property name="Product_Type" expression="//ns1:productDetails/ns1:Product_Type/text()" scope="default" type="STRING"></property>
                  <property name="Source" expression="//ns1:productDetails/ns1:Source/text()" scope="default" type="STRING"></property>
                  <log level="full"></log>
                  <log level="custom">
                     <property name="shcRs : P_ID : " expression="$ctx:Product_ID"></property>
                     <property name="shcRs : P_Name : " expression="$ctx:Product_Name"></property>
                     <property name="shcRs : P_Size : " expression="$ctx:Product_Size"></property>
                     <property name="shcRs : P_Colour : " expression="$ctx:Product_Colour"></property>
                     <property name="shcRs : P_Type : " expression="$ctx:Product_Type"></property>
                     <property name="shcRs : P_Source : " expression="$ctx:Source"></property>
                  </log>
                  <payloadFactory media-type="xml">
                     <format>
                        <productDetails xmlns="">                           
                           <productID></productID>                           
                           <productName></productName>                           
                           <productSize></productSize>                           
                           <productColour></productColour>                           
                           <productType></productType>                           
                           <sourceID></sourceID>                        
                        </productDetails>
                     </format>
                     <args>
                        <arg expression="$ctx:Product_ID" evaluator="xml"></arg>
                        <arg expression="$ctx:Product_Name" evaluator="xml"></arg>
                        <arg expression="$ctx:Product_Size" evaluator="xml"></arg>
                        <arg expression="$ctx:Product_Colour" evaluator="xml"></arg>
                        <arg expression="$ctx:Product_Type" evaluator="xml"></arg>
                        <arg expression="$ctx:Source" evaluator="xml"></arg>
                     </args>
                  </payloadFactory>
                  <log level="custom">
                     <property name="Iterated Message : : :" value="++++++++++++++===================================================+++++++++++++++++=="></property>
                  </log>
                  <log level="full"></log>
                  <sequence key="conf:/pocSearchRsHandlerSeq"></sequence>
               </sequence>
            </target>
         </iterate>
      </then>
      <else>
         <payloadFactory media-type="xml">
            <format>
               <productDetails xmlns="">                  
                  <noItemFound>No item in ShoeCity</noItemFound>               
               </productDetails>
            </format>
         </payloadFactory>
         <sequence key="conf:/pocSearchRsHandlerSeq"></sequence>
      </else>
   </filter>
</sequence>

这是我的响应处理程序:

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="pocSearchRsHandlerSeq">
    <log level="custom">
        <property name="pocSearchRsHandlerSeq reached" value="++++++++++++++=========Aggregating now========+++++++++++++++++=="/>
    </log>
    <aggregate>
        <completeCondition>
            <messageCount min="-1" max="-1"/>
        </completeCondition>
        <onComplete xmlns:ns="http://org.apache.synapse/xsd" expression="//productDetails">
            <log level="custom" separator=",">
                <property name="::::" value="======================= Formatting the Aggregated Responses. ==============="/>
            </log>
            <log level="full"/>
        </onComplete>
    </aggregate>
    <payloadFactory media-type="xml">
        <format>
            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="http://za.co.pepkor/product_service/">
                <soapenv:Body>
                    <prod:productSearchResp>                                                                                                 </prod:productSearchResp>
                </soapenv:Body>
            </soapenv:Envelope>
        </format>
        <args>
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml" expression="//productDetails"/>
        </args>
    </payloadFactory>
    <log level="custom">
        <property name="Full Rs Message : : : " value="++++++++++++++===================================================+++++++++++++++++=="/>
    </log>
    <respond/>
</sequence>

这个序列还从不同的序列接收另一条消息,它确实聚合了(有时)

这是一些回复(全部来自同一个请求)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="http://za.co.pepkor/product_service/">
   <soapenv:Body>
      <prod:productSearchResp>
         <productDetails>
            <productID>2145627</productID>
            <productName>NIKE_SHIRTS</productName>
            <productSize>7</productSize>
            <productColour>RED</productColour>
            <productType>SHIRT</productType>
            <sourceID>ACK</sourceID>
         </productDetails>
         <productDetails>
            <productID>1452168</productID>
            <productName>PUMPS</productName>
            <productSize>7</productSize>
            <productColour>ORANGE</productColour>
            <productType>SHOE</productType>
            <sourceID>SHC</sourceID>
         </productDetails>
      </prod:productSearchResp>
   </soapenv:Body>
</soapenv:Envelope>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="http://za.co.pepkor/product_service/">
   <soapenv:Body>
      <prod:productSearchResp></prod:productSearchResp>
   </soapenv:Body>
</soapenv:Envelope>



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="http://za.co.pepkor/product_service/">
   <soapenv:Body>
      <prod:productSearchResp>
         <productDetails>
            <productID>1452168</productID>
            <productName>PUMPS</productName>
            <productSize>7</productSize>
            <productColour>ORANGE</productColour>
            <productType>SHOE</productType>
            <sourceID>SHC</sourceID>
         </productDetails>
         <productDetails>
            <productID>2145627</productID>
            <productName>NIKE_SHIRTS</productName>
            <productSize>7</productSize>
            <productColour>RED</productColour>
            <productType>SHIRT</productType>
            <sourceID>ACK</sourceID>
         </productDetails>
         <productDetails>
            <productID>1124596</productID>
            <productName>REEBOK_SNEAKERS</productName>
            <productSize>7</productSize>
            <productColour>BROWN</productColour>
            <productType>SHOES</productType>
            <sourceID>SHC</sourceID>
         </productDetails>
      </prod:productSearchResp>
   </soapenv:Body>
</soapenv:Envelope>

我主要得到空响应,我在日志中注意到这些在日志中有以下行,而其他(非空)则没有:

  TID: [0] [ESB] [2015-01-16 16:00:15,770] DEBUG {org.apache.synapse.registry.AbstractRegistry} -  Cached object has expired for key : conf:/ackServiceSearchSeqRs {org.apache.synapse.registry.AbstractRegistry}
TID: [0] [ESB] [2015-01-16 16:00:15,770] DEBUG {org.apache.synapse.registry.AbstractRegistry} -  Expired version number is same as current version in registry {org.apache.synapse.registry.AbstractRegistry}

编辑:

使用带序列键的 "send" 中介和 "sequence" 中介有什么区别?

此外,我可以使用单个 "aggregate" 节点来可靠地聚合来自一个序列中的 "iterate" 的响应和来自不同序列的响应吗?看来我的聚合节点在收集我的所有响应之前过早 "completing",因此执行我的 send/respond(这里有什么不同吗?)调解器。因为我在文档中注意到了这一点:

 Note that when the Iterate mediator is used to split the requests and produces only an n number of fragmented messages, the Aggregate mediator will terminate as soon as it receives n responses, even if you have specified a higher minimum limit.

启用可靠的消息传递给我带来了各种其他问题。

在您的序列 "pocSearchRsHandlerSeq" 中,您应该在 内部 聚合的 onComplete 节点发回您的聚合响应:

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="pocSearchRsHandlerSeq">
    <aggregate>
        <completeCondition>
            <messageCount min="-1" max="-1"/>
        </completeCondition>
        <onComplete xmlns:ns="http://org.apache.synapse/xsd" expression="//productDetails">
            <payloadFactory media-type="xml">
                <format>
                    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="http://za.co.pepkor/product_service/">
                        <soapenv:Body>
                            <prod:productSearchResp></prod:productSearchResp>
                        </soapenv:Body>
                    </soapenv:Envelope>
                </format>
                <args>
                    <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml" expression="//productDetails"/>
                </args>
            </payloadFactory>
            <send/>
        </onComplete>
    </aggregate>
</sequence>

我是这样解决的:

原来我需要一个特定的聚合器来聚合我的迭代消息(分别通过 iterate/aggregate 节点上的 id 属性链接),然后另一个聚合其他响应以及上面的(已经聚合的响应) )

我的响应处理程序:

<sequence xmlns="http://ws.apache.org/ns/synapse">
   <log level="custom">
      <property name="pocSearchRsHandlerSeq reached" value="++++++++++++++=========Aggregating now========+++++++++++++++++=="></property>
   </log>
   <aggregate id="iT">
      <completeCondition>
         <messageCount min="-1" max="-1"></messageCount>
      </completeCondition>
      <onComplete xmlns:ns="http://org.apache.synapse/xsd" expression="//productDetails">
         <log level="custom" separator=",">
            <property name="::::" value="======================= Formatting the Aggregated Responses. ==============="></property>
         </log>
         <log level="full"></log>
      </onComplete>
   </aggregate>
   <aggregate>
      <completeCondition>
         <messageCount min="-1" max="-1"></messageCount>
      </completeCondition>
      <onComplete xmlns:ns="http://org.apache.synapse/xsd" expression="//productDetails">
         <payloadFactory media-type="xml">
            <format>
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="http://za.co.pepkor/product_service/">                  
                  <soapenv:Body>                     
                     <prod:productSearchResp>                                                                                                                                                                                                                   </prod:productSearchResp>                  
                  </soapenv:Body>               
               </soapenv:Envelope>
            </format>
            <args>
               <arg expression="//productDetails" evaluator="xml"></arg>
            </args>
         </payloadFactory>
         <respond></respond>
      </onComplete>
   </aggregate>
</sequence>