This post elaborates a particulate scenario where Aggregation is being implemented using different web service nodes ( SOAP & HTTP Nodes)
Background :
Aggregation is the generation and fan-out of related requests that are derived from a single input message. It is also the fan-in of the corresponding replies to produce a single aggregated reply message.
Broker internally maintains aggregation state in following queues:
Core Aggregation Flows :
Fan Out Flow :
<myms:SaleEnvelope xmlns:myms="http://tempuri.org/MyMS">
<myms:SaleList>
<myms:Invoice>
<myms:Initial>A</myms:Initial>
<myms:Balance>B</myms:Balance>
<myms:Currency>C</myms:Currency>
</myms:Invoice>
</myms:SaleList>
<myms:SaleList>
<myms:Invoice>
<myms:Initial>A1</myms:Initial>
<myms:Balance>B1</myms:Balance>
<myms:Currency>C1</myms:Currency>
</myms:Invoice>
</myms:SaleList>
</myms:SaleEnvelope>
Output :
<ABC>
<AG2>
<SaleEnvelope>
<SaleList>
<Invoice xmlns:NS1="http://tempuri.org/MyMS">
<Initial>a</Initial>
<Balance>60.16</Balance>
<Currency>Dollar</Currency>
</Invoice>
</SaleList>
</SaleEnvelope>
</AG2>
<AG1>
<SaleEnvelope>
<SaleList>
<Invoice xmlns:NS1="http://tempuri.org/MyMS">
<Initial>S</Initial>
<Balance>07.55</Balance>
<Currency>Rupees</Currency>
</Invoice>
</SaleList>
</SaleEnvelope>
</AG1>
</ABC>
Wrapper (Web Service) Flows :
The same flow can be called by HTTPInput Node or SOAPInput Node.
HTTPCaller Flow :
Input :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:myms="http://tempuri.org/MyMS">
<soapenv:Header/>
<soapenv:Body>
<myms:SaleEnvelope>
<myms:SaleList>
<myms:Invoice>
<myms:Initial>A</myms:Initial>
<myms:Balance>B</myms:Balance>
<myms:Currency>C</myms:Currency>
</myms:Invoice>
</myms:SaleList>
<myms:SaleList>
<myms:Invoice>
<myms:Initial>A1</myms:Initial>
<myms:Balance>B1</myms:Balance>
<myms:Currency>C1</myms:Currency>
</myms:Invoice>
</myms:SaleList>
</myms:SaleEnvelope>
</soapenv:Body>
</soapenv:Envelope>
<ABC>
<AG1>
<SaleEnvelope>
<SaleList>
<NS1:Invoice xmlns:NS1="http://tempuri.org/MyMS">
<NS1:Initial>A</NS1:Initial>
<NS1:Balance>B</NS1:Balance>
<NS1:Currency>C</NS1:Currency>
</NS1:Invoice>
</SaleList>
</SaleEnvelope>
</AG1>
<AG2>
<SaleEnvelope>
<SaleList>
<NS1:Invoice xmlns:NS1="http://tempuri.org/MyMS">
<NS1:Initial>A1</NS1:Initial>
<NS1:Balance>B1</NS1:Balance>
<NS1:Currency>C1</NS1:Currency>
</NS1:Invoice>
</SaleList>
</SaleEnvelope>
</AG2>
</ABC>
</soapenv:Body>
</soapenv:Envelope>
Background :
Aggregation is the generation and fan-out of related requests that are derived from a single input message. It is also the fan-in of the corresponding replies to produce a single aggregated reply message.
Aggregation is an advanced form of message routing. With aggregation, a request message is received, and multiple new different request messages are generated. Each new message is routed to its destination using a request-reply interaction.
Aggregation Nodes:
- AggregateControl, AggregateRequest nodes (Used in Fan-Out to broadcast the request message to multiple destinations
- AggregateReply (Used in Fan-In to collect responses)
- ‘Aggregate Name’ property of AggregateControl & AggregateReply nodes should be the same.
- ‘Folder Name’ property of the AggregateRequest node decide how the input will be structured in Fan-Out flow.
- The AggregateReply node creates a folder in the combined message tree below Root, called ComIbmAggregateReplyBody. Below this folder, the node creates a number of subfolders using the names that you set in the AggregateRequest nodes. These subfolders are populated with the associated reply messages.
Broker internally maintains aggregation state in following queues:
- SYSTEM.BROKER.AGGR.REQUEST
- SYSTEM.BROKER.AGGR.CONTROL
- SYSTEM.BROKER.AGGR.REPLY
- SYSTEM.BROKER.AGGR.UNKNOWN
- SYSTEM.BROKER.AGGR.TIMEOUT
Core Aggregation Flows :
Fan Out Flow :
<myms:SaleList>
<myms:Invoice>
<myms:Initial>A</myms:Initial>
<myms:Balance>B</myms:Balance>
<myms:Currency>C</myms:Currency>
</myms:Invoice>
</myms:SaleList>
<myms:SaleList>
<myms:Invoice>
<myms:Initial>A1</myms:Initial>
<myms:Balance>B1</myms:Balance>
<myms:Currency>C1</myms:Currency>
</myms:Invoice>
</myms:SaleList>
</myms:SaleEnvelope>
Output :
<ABC>
<AG2>
<SaleEnvelope>
<SaleList>
<Invoice xmlns:NS1="http://tempuri.org/MyMS">
<Initial>a</Initial>
<Balance>60.16</Balance>
<Currency>Dollar</Currency>
</Invoice>
</SaleList>
</SaleEnvelope>
</AG2>
<AG1>
<SaleEnvelope>
<SaleList>
<Invoice xmlns:NS1="http://tempuri.org/MyMS">
<Initial>S</Initial>
<Balance>07.55</Balance>
<Currency>Rupees</Currency>
</Invoice>
</SaleList>
</SaleEnvelope>
</AG1>
</ABC>
Wrapper (Web Service) Flows :
The same flow can be called by HTTPInput Node or SOAPInput Node.
HTTPCaller Flow :
Input & Output for the above flow would be same as normal flow mentioned above.
Different ways of calling HTTPInput node (Web Service implemented using HTTP nodes) :
- nettool (Its a tool ; Need to give the URL & input xml)
- Another message flow which uses HTTPRequest node to call HTTPCaller flow.
- Java : Can be called through plain Java code; following code sample is a standalone Java program to call HTTPCaller flow.
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class HTTPCaller{
public static void main(String[] args) throws Exception {
// Default port for HTTPInput node is 7080
// Path suffix for URL :/path/to/aggrservice/
URL url = new URL("http://localhost:7080/path/to/aggrservice/");
URLConnection urlConn = url.openConnection();
FileReader fileReader = new FileReader("C://Input.xml"); // Input XML (It is same as above input xml)
urlConn.setDoOutput(true);
InputStreamReader inStream = null;
BufferedReader buff = null;
String nextLine;
String inputLine;
BufferedReader in = new BufferedReader(fileReader);
DataOutputStream printout = new DataOutputStream(urlConn.getOutputStream());
while ((inputLine = in.readLine()) != null){
printout.writeBytes(inputLine);
}
printout.flush();
printout.close();
// Get Response data.
inStream = new InputStreamReader(urlConn.getInputStream());
buff = new BufferedReader(inStream);
while (true) {
nextLine = buff.readLine();
if (nextLine != null) {
System.out.println(nextLine);
} else {
break;
}
}
in.close();
}
}
SOAPCaller Flow :
Input :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:myms="http://tempuri.org/MyMS">
<soapenv:Header/>
<soapenv:Body>
<myms:SaleEnvelope>
<myms:SaleList>
<myms:Invoice>
<myms:Initial>A</myms:Initial>
<myms:Balance>B</myms:Balance>
<myms:Currency>C</myms:Currency>
</myms:Invoice>
</myms:SaleList>
<myms:SaleList>
<myms:Invoice>
<myms:Initial>A1</myms:Initial>
<myms:Balance>B1</myms:Balance>
<myms:Currency>C1</myms:Currency>
</myms:Invoice>
</myms:SaleList>
</myms:SaleEnvelope>
</soapenv:Body>
</soapenv:Envelope>
Output :
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body><ABC>
<AG1>
<SaleEnvelope>
<SaleList>
<NS1:Invoice xmlns:NS1="http://tempuri.org/MyMS">
<NS1:Initial>A</NS1:Initial>
<NS1:Balance>B</NS1:Balance>
<NS1:Currency>C</NS1:Currency>
</NS1:Invoice>
</SaleList>
</SaleEnvelope>
</AG1>
<AG2>
<SaleEnvelope>
<SaleList>
<NS1:Invoice xmlns:NS1="http://tempuri.org/MyMS">
<NS1:Initial>A1</NS1:Initial>
<NS1:Balance>B1</NS1:Balance>
<NS1:Currency>C1</NS1:Currency>
</NS1:Invoice>
</SaleList>
</SaleEnvelope>
</AG2>
</ABC>
</soapenv:Body>
</soapenv:Envelope>
Different ways of calling SOAPInput node (Web Service implemented using SOAP nodes) :
- SoapUI (Its a tool ; Need to give wsdl & input xml)
- Another message flow which uses SOAPRequest node to call SOAPCaller flow.
- Java : Can be called through plain Java code; following post has example of how to call a web service: http://harishonsoa.blogspot.com/2011/12/calling-any-service-using-webservice.html
// Default port for SOAPInput node is 7800
// Path suffix for URL : /MyMSSOAP_HTTP_Service ; so the URL would be http://localhost:7800/MyMSSOAP_HTTP_Service?wsdl
RequestIdentifier to be set in HTTP Flow and
ReplyDeleteReplyIdentifier to be set in SOAP Flow........
Hi,
ReplyDeleteCan u suggest how to send message from a web page like jsp to message queue in message explorer ?
Hi,
ReplyDeleteThx a lot, very clear explanation.
kamal
I have never seen such a wonderful article. I thank you so much for publishing this article which made me learn aggregation in 1 hr.
ReplyDeleteHi
ReplyDeleteIs the schema level variable 'RequestIdentifier' value shared between different flows? Im trying this and it seems when the message gets out of scope of the HTTP node's flow into the MQ application flow the value is gone. Am i missing something here?
Yes you cannot unless you use a MQGet in the flow and copy it to Environment, this is where Architects goof up in design. For earlier vesrions before MQGet Node was introduced it was by storing the Header on a queue and comparing based on correlation.
DeleteThis comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteI am looking for some guidance for creating the solution for my requirement.
I have a situation where backed gives response for only certain number of( for example 2) employee Id . But I can receive for than that count as a part of request.As a part of project requirement I have to make parallel call to backed if I am receiving more 2 EMP id as a part of my request, than I have to collate the response and pass final response to the backed. backend call is HTTPs.
Please help
hello harish,
ReplyDeletecan you please eloborate why we have declared the schema level namespace?
i am new to iib
Web Design & Development company offering the web services, So,people should analyze which company would provide best performance and which one is satisfy our expectation in web design services Delhi.
ReplyDeleteWeb Designing Company in Delhi, Web Development Company Delhi
Hi everyone,
ReplyDeleteIn Cloud light weight version ..they are not giving support for Aggregation.So i need to achieve this functionality by using alternative way.
Can you guys suggest me with ur suggestions ?
Thanks in advanced