Alka
Alka

Reputation: 95

Sending single request to call different systems in WSO2 ESB

Hi I have a scenario in which I need to send just one request (can be a proxy url) which can call multiple endpoints and return the response after aggreating all of them.

Currently I am using a proxy service implementation to achieve it but is returns just one response(can be from any of the endpoints) and not able to combine responses from other systems/endpoints. Though I can the response from another endpoint in my server console.

Below is the code I implemented so far:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="RLProxy"
       transports="http,https"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <clone>
            <target>
               <sequence>
                  <property name="Authorization"
                            value="Basic username:password"
                            scope="transport"/>
                  <property name="messageType"
                            value="application/json"
                            scope="axis2"
                            type="STRING"/>
                  <send>
                     <endpoint>
                        <address uri="http://localhost:7070/adap/cn=AlkaA,ou=People,dc=maxcrc,dc=com"/>
                     </endpoint>
                  </send>
               </sequence>
            </target>
            <target>
               <sequence>
                  <property name="Authorization"
                            value="Basic username:password"
                            scope="transport"/>
                  <property name="messageType"
                            value="application/json"
                            scope="axis2"
                            type="STRING"/>
                  <send>
                     <endpoint>
                        <address uri="http://localhost:7070/adap/cn=AlkaV,ou=People,dc=maxcrc,dc=com"/>
                     </endpoint>
                  </send>
               </sequence>
            </target>
         </clone>
         <aggregate>
            <completeCondition>
               <messageCount min="3"/>
            </completeCondition>
            <onComplete expression="$body/jsonObject">
               <send/>
            </onComplete>
         </aggregate>
      </inSequence>
   </target>
   <description/>
</proxy>

I am guessing there is some issue with aggregate expression. I don't know how is works. Please help me. If there is some other issue please let me know how to fix it.Right now I am testing just one scenario with the same system endpoints having different search for LDAP but I need to implement it for different kinds of systems. In am stuck with it for many days. Please help.

Upvotes: 1

Views: 803

Answers (1)

Amila Maharachchi
Amila Maharachchi

Reputation: 2149

You have placed the aggregate mediator inside the inSequence. But, it has to be placed in the outSequence. Thats the place the responses from the backend requests arrive.

Furthermore, if you are invoking just two endpoints, it doesn't look correct to have the minimum message count to wait before aggregation to 3.

Refere the following documentation and samples for aggregate mediator.

https://docs.wso2.com/display/ESB490/Aggregate+Mediator

https://docs.wso2.com/display/ESB490/Sample+400%3A+Message+Splitting+and+Aggregating+the+Responses

Upvotes: 1

Related Questions