Data Correlation Based on Activity

Data Correlation

We use correlation to keep track of related messages in a sequence of message exchanges. For example, the purchase order and the sales will have the same order number. To ensure that the purchase order and the corresponding sales operations are correlated, we can assign a correlation using the purchase order number. In finding correlation we have to define the elements that are relevant to the messages to be correlated with.

Correlating the Messages

Here we correlate the messages at SOAP level. Each message that comes to the server can include an activity ID. When multiple messages have the same activity ID, we could find the correlation among their invocations.

When messages come to the server, events will be generated using WS-Eventing model. These events will be captured by WSO2 BAM server and datas will be collected based on the activity ID.

Generating Activity IDs

When we initiate a request to a service, we can create an activity ID for that message as a SOAP header block. Activity ID is an UUID which contains 45 characters. With the activity ID we can assign a name and a description for the activity. If we don't assign a name or a description, server will assign an empty string automatically for them.

Sample SOAP header

			<soapenv:Header> 
	     			 <ns:BAMEvent xmlns:ns="http://wso2.org/ns/2010/10/bam" activityID="	urn:uuid:2864E8C4EB492D734516373634197645666503169"> 
		    			 <ns:Property name="order details" value="Order Id 100" /> 
	      			 </ns:BAMEvent> 
    		 	</soapenv:Header>

		 

NOTE: SOAP headers should contain Name and the Description for each message(If user wants a description). Keeping an activity ID block depends on user's wish. If user doesn't define an activity ID, the server will generate one and populate it along with the message.

Activity and Message Level Events

To generate the events from the service host environment to the BAM server, we have an event publisher based on WS-Eventing model. Activity data publisher component should be deployed at the service hosting environment(e.g.: WSO2 WSAS) to generate events. When messages hit this server they will generate events and subscriber component which is deployed at the WSO2 BAM server will receive those events.

Sample event pay-load

      		<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  				<activitydata:Event xmlns:activitydata="http://wso2.org/ns/2009/09/bam/service/activity/data">
  					<activitydata:ServiceActivityData>
  						<activitydata:ServerName>https://10.10 0.1.143:9443</activitydata:ServerName>
  						<activitydata:ActivityID>prash491-a03a-426 0-b177-c493ab7a2dbb</activitydata:ActivityID>
  						<activitydata:MessageID>urn:uuid:9D0122788E12AC73B21260297714047</activitydata:MessageID>
 						<activity data:ServiceName>SampleHelloService</activitydata:ServiceName>
  						<activitydata:OperationName>sayHello</activitydata:OperationName>
  						<activitydata:ActivityName>hello2 </activitydata:ActivityName>
 						<activitydata:ActivityDescription>say hello2</activitydata:ActivityDescription>
  						<activitydata:RemoteIPAddress>127.0.0.1</activitydata:RemoteIPAddress>
  						<activitydata:UserAgent>%%%%%</activitydata:UserAgent>
 					 </activitydata:ServiceActivityData>
  				</activitydata:Event>
  			</soapenv:Body>
         

From the above event pay-load, we collect the following data related to a message: