Mediation Data Agents

Installing BAM Data Agent Feature

The following installation instructions apply to WSO2 ESB version 4.0.x

  1. Download the WSO2 ESB server.
  2. As we are running both ESB and BAM server concurrently we should change the port number of ESB by applying an offset. In order to apply an offset, in the ESB product directory go to $esb_home/repository/conf and open file, carbon.xml . Then change the value in xpath Server/Ports/Offset from '0' to some other integer.
  3. To start the server, on Linux

    wso2server.sh

    on MS Windows

    wso2server.bat

    Start WSO2 ESB on Linux,

    start-ESB-linux

  4. After starting the server, go to ESB management console Configure→Features→Settings menu.

    Give P2 repository link either from as a URL or from a file.

    add-feature-from-p2repo

    Then click 'Add'.

  5. Go to 'Available Features' tab and select the above repository.

    find-features-from-p2repo

    Click 'Find Features'.

    see-all-features-in-p2repo

    User can see all available features. From those, select 'BAM Mediation Data Agent Aggregate' feature.

    select-feature-p2repo

    Click 'Install'.

    after-click-Install-button-in-features

  6. Click 'Next' and accept the license agreement.

    click-next-to-feature-agreement

    installing-feature

    feature-instalation-complete

  7. Restart the WSO2 ESB server.

    shutdown-or-restart-server

    confirm-restart-server

    server-is-restarting

Setting the Backend Server

  1. In the ESB product directory go to $esb_home/samples/axis2Server/src/SimpleStockQuoteService and build the backend service with Apache Ant. (You need to install Apache Ant before that.)

    ant-backend-server-simpleStockQuoteService

  2. Go to $esb_home/samples/axis2Server and run the Axis2 server.

    For Linux,

    axis2server.sh

    For Windows,

    axis2server.bat
  3. Now test whether the proxy service WSDL exists in http://localhost:9000/services/SimpleStockQuoteService?wsdl

    wsdl-for-proxy-service

Adding a proxy service to WSO2 ESB

  1. Go to ESB management console and select Main→Web Services→Add→Proxy Service from the side panel.

    goto-proxy-services

  2. Click on 'WSDL Based Proxy' to create a new WSDL based proxy.
  3. Fill the form.
    1. Insert suitable Proxy Service Name (eg: Simple_Stock_Quote_Service).
    2. Set http://localhost:9000/services/SimpleStockQuoteService?wsdl as the WSDL URI.
    3. Set 'SimpleStockQuoteService' as the WSDL Service.
    4. Set 'SimpleStockQuoteServiceHttpSoap11Endpoint' as the WSDL Port.

    add-wsdl-proxy-service

  4. Click 'Create'.

    adding-wsdl-proxy-successful

  5. Select newly created proxy's name (here 'Simple_Stock_Quote_Service') form the shown list to see the Service Dashboard of it.

    dashboard-newly-created-proxy

  6. Now click 'Enable Statistics' to set the ESB to send statistics to the BAM.

Configuring Mediation Data Publisher

  1. Go to ESB management console and select Configure→Mediation Data Publishing from side panel.
  2. Fill the form.
    1. Tick on 'Enable Mediation Stats'.
    2. Set the 'BAM URL' as the URL of the BAM server. e.g. : https://localhost:9443
    3. Set user name and password as 'admin'.
    4. Let the default setting and value remain for 'socket' and 'port' in 'Transport'.

    mediation-datapub-configuration

  3. Click 'Update'.

    mediation-data-publisher-config-successfully-updated

  4. Sample data format for mediation statistic data agent as follows.
    event data
    
    => key=avg_processing_time, value=0.5
    => key=count, value=2
    => key=direction, value=Out
    => key=fault_count, value=0
    => key=max_processing_time, value=1
    => key=min_processing_time, value=0
    => key=resource_id, value=EchoProxy
    => key=stats_type, value=Proxy
    => key=timestamp, value=2012-03-12 11:21:33.766
    

Configuring Activity Publisher

  1. Go to ESB management console and select Configure→Activity Publishing from side panel.
  2. Fill the form.
    1. Tick on 'Enable Activity Mediation'.
    2. Set the 'BAM URL' as the URL of the BAM server. e.g. : https://localhost:9443
    3. Set user name and password as 'admin'.
    4. Let the default setting and value remain for 'socket' and 'port' in 'Transport'.

    activity-publisher-configuration

  3. Click 'Update'.

    activity-publisher-config-successfully-updated

  4. Sample data format for activity mediation data agent as follows.
    event data
    
    => key=bam_activity_id, value=06956a7c-caff-49b9-b3a9-9ccacf4ec026
    => key=message_body, value=<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><ns:echoIntResponse xmlns:ns="http://echo.services.core.carbon.wso2.org"><return>1</return></ns:echoIntResponse></soapenv:Body>
    => key=message_direction, value=OUT
    => key=message_id, value=urn:uuid:8f4b9e1f-50e2-40d9-849c-79171df5c54a
    => key=operation_name, value=echoInt
    => key=service_name, value=EchoProxy
    => key=soap_envelop_namespace, value=http://schemas.xmlsoap.org/soap/envelope/
    => key=timestamp, value=2012-03-13 03:36:47.474
    
    
    Correlation data
    
    => key=bam_activity_id, value=6a390b7b-00a5-4330-ab6b-0ceff81ce16a
    

Configuring ESB

  1. Go to ESB management console and select Main→Source View from side panel.

    esb-configuration-in-source-view

  2. Include the following 'inSequence' xml to the xpath, definitions/proxy/target in the shown ESB configuration.
    	<inSequence>
    		<class name="org.wso2.carbon.bam.activity.mediation.data.publisher.mediator.MessageActivityMediator">
    			<property name="extractSoapBody" value="true"/>
    		</class>
    	</inSequence>
    

    add-inSequence-to-esb-configuration

  3. Click 'Update'.

    esb-configuration-updated-successfully

Send Request From the Client

  1. In the ESB product directory go to $esb_home/samples/axis2Client
  2. Build the backend service with Apache Ant (You need to install Apache Ant before that.) with the following code.
    ant stockquote -Daddurl=https://localhost:8244/services/Simple_Stock_Quote_Service -Dmode=fullquote
    

    ant-backend-service-Simple_Stock_Quote_Service

    (Here 'addurl' value should be given from the https endpoint located in Simple_Stock_Quote_Service's service dashboard that can be navigated by going to the ESB management console Main→Web Services→List from side panel and selecting 'Simple_Stock_Quote_Service' )

    finding-endpoint-url-in-dashboard

    Now the proxy service Simple_Stock_Quote_Service should have dumped statistics and messages from the ESB to the EVENT table in the Cassandra database. Data in the Cassandra database can be seen by from the CLI using Cassandra Client.

    dumped-message-in-database

    Using the BAM server it can execute analyzers and store results to summary tables which can be visualized by the Gadget IDE in BAM.