2

I am doing iteration over the DSS response, But not working as expected

Below is the payload and call for DSS:

<payloadFactory media-type="xml">
      <format>
         <p:getNominaIDDetails xmlns:p="http://ws.wso2.org/dataservice">
            <xs:column1 xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:column1>
            <xs:column2 xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:column2>
            <xs:column3 xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:column3>
            <xs:column4 xmlns:xs="http://ws.wso2.org/dataservice">$4</xs:column4>
         </p:getNominaIDDetails>
      </format>
      <args>
         <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column1')" evaluator="xml"></arg>
         <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column2')" evaluator="xml"></arg>
         <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column3')" evaluator="xml"></arg>
         <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column4')" evaluator="xml"></arg>
      </args>
   </payloadFactory>

   <header name="Action" scope="default" value="urn:xxxxxxx"></header>
   <call>
      <endpoint key="gov:/dss/endpoint"></endpoint>
   </call>
    <filter xmlns:ns="http://org.apache.synapse/xsd"
           xmlns:ds="http://ws.wso2.org/dataservice"
           xpath="get-property('db_count')&gt;0">
      <then>
         <iterate id="xxx"
                  preservePayload="true"
                  attachPath="//ds:xxxx"
                  expression="//ds:xxx/ds:xxx">
            <target sequence="My_seq">
            </target>
         </iterate>
      </then>
      <else>
         <drop/>
      </else>
   </filter>

Response from the dss is:

<response xmlns="http://ws.wso2.org/dataservice">       
        <id>
            <column1>234</column1>
            <column1>4455</column1>
            <column1>567778</column1>
        </id>
        <id>
            <column1>546</column1>
            <column1>56866</column1>
            <column1>464453</column1>
        </id>
        <id>
            <column1>546</column1>
            <column1>56866</column1>
            <column1>464453</column1>
        </id>
    </response>

With the above response completing with first iteration and remaining all the messages expiring after global timeout.Below are the logs after first iteration:

{org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2016-09-04 06:26:13,471]  WARN {org.apache.synapse.core.axis2.SynapseCallbackReceiver} -  Synapse received a response for the request with message Id : urn:uuid:c62d7dae-5290-49d1-b1bd-b5d2dcba7e04 But a callback is not registered (anymore) to process this response {org.apache.synapse.core.axis2.SynapseCallbackReceiver}
TID: [0] [ESB] [2016-09-04 06:26:42,144]  WARN {org.apache.synapse.core.axis2.TimeoutHandler} -  Expiring message ID : urn:uuid:36df3897-73be-4bc3-a434-aaab618c7ce3; dropping message after global timeout of : 180 seconds {org.apache.synapse.core.axis2.TimeoutHandler}
TID: [0] [ESB] [2016-09-04 06:26:42,145]  WARN {org.apache.synapse.core.axis2.TimeoutHandler} -  Expiring message ID : urn:uuid:d8ec8998-95c6-4d70-9e33-c11bda271e90; dropping message after global timeout of : 180 seconds {org.apache.synapse.core.axis2.TimeoutHandler}

Note: inside iterator doing following operations(sequence="My_seq")

perfoming the Bank call-->DSS call-->SAP call using call meditor

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="My_seq" >
    <property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ds="http://ws.wso2.org/dataservice" name="id" expression="//ds:dss_response/ds:Id" scope="default" type="STRING"/>
    <payloadFactory media-type="xml">
        <format>
            <h:opertion xmlns:h="http://ws.wso2.org/xxxxxx">
                <h2h:id>$1</h2h:id>
            </h:opertion>
        </format>
        <args>
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml" expression="get-property('id')"/>
        </args>
    </payloadFactory>
    <property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode('xxxxx:xxxxxxxx'))" scope="transport" type="STRING"/>
    <property name="ContentType" value="application/soap+xml" scope="axis2" type="STRING"/>
    <property name="messageType" value="application/soap+xml" scope="axis2" type="STRING"/>
     <call>
        <endpoint key="gov:/endpoint"/>
     </call>
    <sequence key="next_sequence_to_be_DSS_then_SAP"/>
</sequence>
Siddu
  • 91
  • 10
  • Your config looks fine. Can you enabled wire logs and update your question with logs? http://mytecheye.blogspot.com/2013/09/wso2-esb-all-about-wire-logs.html – Bee Sep 04 '16 at 15:13
  • post your "My_seq" config too – Bee Sep 04 '16 at 15:15
  • @Bhathiya as my wired logs too big i think can't share, is there any other way to share all the logs and code? – Siddu Sep 04 '16 at 17:46
  • As i can see in the wired logs, Issue with "call mediator" used for the bank call.Basically It should fire and forgot but it is not happening and waiting for the response after that going into SUSPENDED state. – Siddu Sep 04 '16 at 18:15

1 Answers1

1

I believe this should suit your requirement. Here I'm checking status of incoming responses and send OK to client only if every request was successful.

<api xmlns="http://ws.apache.org/ns/synapse" name="MyAPI" context="/myapi">
   <resource methods="POST GET" url-mapping="/">
      <inSequence>
         <call blocking="true">
            <endpoint>
               <http uri-template="http://www.mocky.io/v2/57cd6f422d00000101b15868"/>
            </endpoint>
         </call>
         <property name="Staus" value="OK" type="STRING"/>
         <iterate xmlns:ds="http://ws.wso2.org/dataservice" id="xxx" preservePayload="true" expression="//ds:response/ds:id">
            <target>
               <sequence>
                  <send>
                     <endpoint>
                        <http uri-template="http://www.mocky.io/v2/57cd70c22d00002401b1586c"/>
                     </endpoint>
                  </send>
               </sequence>
            </target>
         </iterate>
      </inSequence>
      <outSequence>
         <filter source="$axis2:HTTP_SC" regex="200">
            <then/>
            <else>
               <property name="Staus" value="NOT OK" type="STRING"/>
            </else>
         </filter>
         <aggregate id="xxx">
            <completeCondition>
               <messageCount/>
            </completeCondition>
            <onComplete xmlns:ds="http://ws.wso2.org/dataservice" expression="/">
               <log level="custom">
                  <property name="Final Staus" expression="$ctx:Staus"/>
               </log>
               <payloadFactory media-type="xml">
                  <format>
                     <status>$1</status>
                  </format>
                  <args>
                     <arg evaluator="xml" expression="$ctx:Status"/>
                  </args>
               </payloadFactory>
               <send/>
            </onComplete>
         </aggregate>
      </outSequence>
   </resource>
</api>
Bee
  • 12,251
  • 11
  • 46
  • 73
  • I am excepting response, will get response from bank and transform sending back to SAP...this is one iteration, Like this for many iteration should happens. But my case it is stopping with first iteration – Siddu Sep 04 '16 at 18:27
  • In the first iteration am getting response while trying for second iteration timeout happening or going into SUSPENDED state – Siddu Sep 04 '16 at 18:31
  • what kind of response are you expecting? Is that an aggregate response? – Bee Sep 04 '16 at 18:42
  • Your requirement is not clear. Earlier you said `It should fire and forgot`. And here you say you expect a response. – Bee Sep 04 '16 at 18:47
  • I am getting encrypted format of response from the bank, there is no aggregation in response. – Siddu Sep 05 '16 at 10:40
  • what i meant is, should make blocking call to the bank service so that it will continue with other iterations...Here i tried with both call/send mediator but its not making blocking call. – Siddu Sep 05 '16 at 10:43
  • mm.. still im confused. let me tell you what I understood. correct me if I'm wrong. You do a call to DSS. it gives above response. you need to split it and send each of them to bank service, and each of those responses are sent to another dss service. And the responses of those need to be sent to SAP. at the end you need a response. Is that correct. What are the information you need in this response? – Bee Sep 05 '16 at 12:18
  • You do a call to DSS. it gives above response. you need to split it and send each of them to bank service, and each of those responses are sent to another dss service. And the responses of those need to be sent to SAP. at the end i need to update Database only if SAP call success. – Siddu Sep 05 '16 at 12:35
  • If any error occurs in the first iteration while sending to SAP it should not update database but it should continue with other iterations. – Siddu Sep 05 '16 at 12:37
  • I hope u understood my problem, waiting for the solution – Siddu Sep 05 '16 at 12:39
  • What does SAP return in successful and unsuccessful requests? just status codes? – Bee Sep 05 '16 at 12:48
  • You do a call to DSS. it gives above response. you need to split it and send each of them to bank service...Here it self it not happening, What happening here is its done with first iteration and remaining all iteration dropping after global timeout.(used "call mediator" to call bank service) – Siddu Sep 05 '16 at 13:10
  • Can you share your sequence? – Bee Sep 05 '16 at 13:11
  • seq added in my post, please have a look and let me know – Siddu Sep 05 '16 at 13:22