0

I have been busy refactoring my sequences and proxy ( see WSO2 Aggregate Mediator premature/incomplete/unknown completion ). After I had gotten it working as per previous question , it has produced some unwanted behaviour. I only changed the names of the sequences , nothing else.

Now after my second aggregator :

<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>                                                                                                                   $1                                                                                                </prod:productSearchResp>                  
                  </soapenv:Body>               
               </soapenv:Envelope>
            </format>
            <args>
               <arg expression="//productDetails" evaluator="xml"></arg>
            </args>
         </payloadFactory>
         <respond></respond>
      </onComplete>
   </aggregate>
</sequence>

Now ,it is dropping(or forgetting) that aggregated message (which previously looked like this for example) :

?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <productDetails>
            <productID>1452168</productID>
            <productName>PUMPS</productName>
            <productSize>7</productSize>
            <productColour>ORANGE</productColour>
            <productType>SHOE</productType>
            <sourceID>SHC</sourceID>
        </productDetails>
        <productDetails>
            <productID>1124596</productID>
            <productName>REEBOK_SNEAKERS</productName>
            <productSize>7</productSize>
            <productColour>BROWN</productColour>
            <productType>SHOES</productType>
            <sourceID>SHC</sourceID>
        </productDetails>
        <productDetails>
            <productID>1123456</productID>
            <productName>NIKE_SHIRTS</productName>
            <productSize>7</productSize>
            <productColour>RED</productColour>
            <productType>SHIRT</productType>
            <sourceID>SHC</sourceID>
        </productDetails>
    </soapenv:Body>
</soapenv:Envelope>

And sending in this to be secondarily aggregated instead :

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body></soapenv:Body></soapenv:Envelope> 

I am getting a lot of these empty messages back into my proxies outSequence for some reason :

TID: [0] [ESB] [2015-02-25 16:22:01,023] DEBUG {org.apache.synapse.core.axis2.SynapseCallbackReceiver} -  Synapse received an asynchronous response message {org.apache.synapse.core.axis2.SynapseCallbackReceiver}
TID: [0] [ESB] [2015-02-25 16:22:01,023] DEBUG {org.apache.synapse.mediators.base.SequenceMediator} -  Start : Sequence <ackServiceSearchSeqRs> {org.apache.synapse.mediators.base.SequenceMediator}
TID: [0] [ESB] [2015-02-25 16:22:01,023] DEBUG {org.apache.synapse.core.axis2.SynapseCallbackReceiver} -  Received To: null {org.apache.synapse.core.axis2.SynapseCallbackReceiver}
TID: [0] [ESB] [2015-02-25 16:22:01,024] DEBUG {org.apache.synapse.mediators.base.SequenceMediator} -  Sequence <SequenceMediator> :: mediate() {org.apache.synapse.mediators.base.SequenceMediator}
TID: [0] [ESB] [2015-02-25 16:22:01,024] DEBUG {org.apache.synapse.core.axis2.SynapseCallbackReceiver} -  SOAPAction:  {org.apache.synapse.core.axis2.SynapseCallbackReceiver}
TID: [0] [ESB] [2015-02-25 16:22:01,024] DEBUG {org.apache.synapse.mediators.base.SequenceMediator} -  Mediation started from mediator position : 0 {org.apache.synapse.mediators.base.SequenceMediator}
TID: [0] [ESB] [2015-02-25 16:22:01,024] DEBUG {org.apache.synapse.core.axis2.SynapseCallbackReceiver} -  WSA-Action:  {org.apache.synapse.core.axis2.SynapseCallbackReceiver}
TID: [0] [ESB] [2015-02-25 16:22:01,025] DEBUG {org.apache.synapse.core.axis2.SynapseCallbackReceiver} -  Body : 
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body></soapenv:Body></soapenv:Envelope> {org.apache.synapse.core.axis2.SynapseCallbackReceiver}

At least 2 everytime. I have disabled continueParent.

EDIT

Check out WSO2 ESB : Aggregate node droppping message after aggregation for more background info

Community
  • 1
  • 1
MiddlewareManiac
  • 570
  • 4
  • 19

1 Answers1

0

In the onComplete of <aggregate id="iT"> , you will have the aggregated productDetails as follow

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

so you can add the root element <prod:productSearchResp> to soap body with payload factory mediator.

<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> $1                                                                                                </prod:productSearchResp>
                </soapenv:Body>
            </soapenv:Envelope>
        </format>
        <args>
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml" expression="//productDetails"/>
        </args>
    </payloadFactory>

No need for second aggregate and having payload factory mediator within that.

Jenananthan
  • 1,381
  • 2
  • 10
  • 20
  • No , like I said in my prev question , an Aggregator node will terminate after receiving x number of iterated messages from Iterator mediator , so will disregard any other messages. For instance if I have 1 aggregator , as you suggest , and this handler Sequence receives 5 mssgs from an Iterator , and 1 more from another sequence ,it will terminate(execute onComplete) after receiving 5 messages , instead of 6. – MiddlewareManiac Feb 26 '15 at 15:26
  • ok then what did you get for of first aggregate? – Jenananthan Feb 27 '15 at 08:50
  • In the second aggregat you need to give the min and message count.since that aggreagte is doesn't play with any iterate mediator – Jenananthan Feb 27 '15 at 09:08