Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

BAM Mediator is a mediator for WSO2 ESB that captures data events from the ESB mediation sequences and sends to any server with a listening Thrift port such as WSO2 BAM or WSO2 CEP servers. The Thrift port receives data events via a Thrift API. It uses a binary protocol and enables fast data transmission between the ESB and a Thrift port.

You can configure the BAM mediator and the data to be extracted from ESB configuration context. In the configuration panel, you can specify each Thrift server profile with a set of event streams that can be used at the BAM mediator declaration time. When a BAM mediator is declared in an ESB sequence, you should select a server profile from the given list and a stream (uniquely identified by a name and a version) available in the selected server profile.

Info

NOTE: The steps below show how to set up WSO2 BAM as the Thrift server, but the same steps apply to any server with a listening Thrift port, such as WSO2 CEP.

Setting up the BAM mediator

The procedure for setting up the BAM mediator depends on the ESB version you use. Click on the relevant tab for instructions to set up the BAM mediator for the selected ESB version.

Localtab Group
Localtab
titleESB 4.6.0 and later
  1. Download the relevant ESB version from http://wso2.com/products/enterprise-service-bus.
  2. Since both the BAM and ESB servers are run concurrently, it is required to change the default port for one of the servers in order to avoid port conflicts. In this example, the default port of ESB can be changed by updating the <ESB_HOME>/repository/conf/carbon.xml file as follows.

    Code Block
    languagehtml/xml
    <!-- Ports offset. This entry will set the value of the ports defined below to the define value + Offset. e.g. Offset=2 and HTTPS port=9443 will set the effective HTTPS port to 9445-->
    <Offset>2</Offset>
  3. Start the WSO2 ESB server by running one of the following commands in your CLI.
    • on Linux, run <ESB_HOME>/bin/wso2server.sh
    • on MS Windows, run <ESB_HOME>/bin/wso2server.bat

Localtab
titleESB 4.5.x and earlier
  1. Download the relevant ESB version from http://wso2.com/products/enterprise-service-bus.
  2. Since both the BAM and ESB servers are run concurrently, it is required to change the default port for one of the servers in order to avoid port conflicts. In this example, the default port of ESB can be changed by updating the <ESB_HOME>/repository/conf/carbon.xml file as follows.

    Code Block
    languagehtml/xml
    <!-- Ports offset. This entry will set the value of the ports defined below to the define value + Offset. e.g. Offset=2 and HTTPS port=9443 will set the effective HTTPS port to 9445-->
    <Offset>2</Offset>
  3. Start the WSO2 ESB server by running one of the following commands in your CLI.
    • on Linux, run <ESB_HOME>/bin/wso2server.sh
    • on MS Windows, run <ESB_HOME>/bin/wso2server.bat 

  4. Click the Configure tab in the left navigator and click Features to open the Feature Management page. In this page, click the Repository Management tab.
  5. Add a new P2 repository using either a URL or from a file system. For more information on adding a P2 feature repository, see Managing the Feature Repository .
  6. Click the Available Features tab. In the Repository parameter, select the repository you added in the previous step.
  7. Clear the Show only the latest versions and Group features by category check boxes and then click Find Features. Once the features are listed, select the BAM Mediator Aggregate feature.
     

    Info

    It may take a while to list all the available features.

    Tip

    If you cannot see this feature in the list of features, try one of the following options.

    • Add a more recent P2 repository. The repository you added may be deprecated.
    • Check the Installed Features tab to see whether the feature is already installed.
  8. Click Install to proceed with the installation.
  9. Once the installation is complete, restart WSO2 ESB. For more information on feature installation, see Installing and Managing Features .

Using BAM Mediator

The following sections explain how to use the existing BAM Mediator configuration when editing a mediation sequence, using a sample scenario.

Table of Contents
maxLevel4
minLevel4

Configuring server profiles and streams
Anchor
Configure BAM Server Profiles and Streams
Configure BAM Server Profiles and Streams

Before adding a BAM mediator to a mediator sequence, you must update the BAM mediator configurations. Configuration information is considered as a set of BAM server profiles, which contain transport and credential data required to connect to the BAM server. In each BAM server profile, you must define one or many event stream configurations. Streams contain Thrift API event stream related information like Stream Name, Stream Version etc. and the data to be extracted from the configuration context of the mediation sequence. The steps below explain this.

  1. Navigate to the ESB management console and select Configure -> BAM -> Server Profile menu.
  2. If there are no existing profiles, add one using the Add Profile link. If there are existing profiles, you can edit them using the Edit Profile link.
  3. Enter the profile information in the page that opens. For example,Some of the fields are described below:

    • Server Credential: admin/admin by default
    • Server Transport: Thrift as the default Protocol
    • Enable Load Balancer: Enable if want to load balance with Thrift from the client side to several hosts. Then enter comma separated connection URLs of hosts as URL Set. e.g.: tcp://10.200.3.218:7611, tcp://10.100.3.97:7611. refer more details on using load balancing publishing in this page.
    • Enable Security: If message confidentiality is required from ESB server to BAM server, select this option.
    • IP Address: IP of the BAM server's Thrift server. By default, it is the IP address of the localhost.
    • Receiver Port:  If security is not enabled, this option will have to be given. Enter 7611 by default, which is the Thrift server port.
    • Authentication Port: Port number is Receiver Port + 100, which is 7711.
    • Test Server button: Using this, availability of the BAM server can be tested for the given IP Address and the Authentication Port.
  4. Define a set of stream configurations. For example,
    Each stream must have the following defined:

    • Name: Stream Name can be any string with alpha-numeric characters.
    • Version: Stream Version distinguishes different streams with the same Stream Name. Default version should be 1.0.0.
    • Nickname: This is a user-preferred nick name to the Stream Name in alpha-numeric characters.
    • Description: A description about the particular stream defined by Stream Name/Stream Version pair. Description should also consist of alpha-numeric characters.
    • Dump header/Dump body, options: If you want to record SOAP header or SOAP body of messages respectively. 
    • Stream Properties: You can extract several types of properties from the message. Properties are divided into two as Value and Expression.
      • Value: A constant alpha-numeric string value entered to Value field is set as the property.
      • Expression: The given expression in Value field is considered as an expression and executed on the message to get the property. XPath properties and functions available in ESB are valid in the expression. (Note : At the moment, there is no way to add namespaces to xpath expressions which is to be completed in future. It is given in JIRA https://wso2.org/jira/browse/BAM-539 . As a workaround, you can use Property Mediator in ESB, to get the xpath and add it to the message context as a property which can then be captured from the BAM mediator using the get-property expression.)
      • Type drop down list: The required type to be converted in which the property should be sent via Thrift
       
    At the time you define the mediator definition, you can select a stream from the ones you define here.
  5. After Stream Payload and Stream Properties are added/edited, click Update to reflect changes in the specific stream configuration.
  6. Once all configurations are made to the BAM Server Profile, click Save.
  7. Click the BAM Server Profile link at the top of the page to see the new profiles. Similarly, you can add any number of server profiles and unique stream configurations under one BAM server profile.

Setting the backend server for ESB endpoint

In order to test the functionality of the BAM mediator, you must define a sample WSDL proxy service along with an endpoint service to the WSDL proxy service. Here are the steps to create an endpoint service:

  1. Navigate to <ESB_HOME>/samples/axis2Server/src/SimpleStockQuoteService/ directory and build the backend service with Apache Ant (You must have Apache Ant installed).
  2. Navigate to <ESB_HOME>/samples/axis2Server/ directory and run the Axis2 server.

    • In Linux: axis2server.sh
    • In Windows: axis2server.bat
  3. Test whether the proxy service WSDL exists in the following URL:  http://localhost:9000/services/SimpleStockQuoteService?wsdl.

Adding a proxy service to the ESB

These are the steps to create a sample WSDL Proxy Service to test the BAM mediator.

  1. Go to ESB management console and select Main→Web Services→Add→Proxy Service from the side panel.
  2. Click Based Proxy to create a new WSDL based proxy.
  3. Fill the form as follows:
    1. Insert a suitable Proxy Service Name (E.g. Simple_Stock_Quote_Service_Proxy).
    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.
  4. Click Create.
  5. Click on the newly created proxy's name (Simple_Stock_Quote_Service_Proxy in this case) to go to its dashboard.

Adding BAM Mediator to WSDL proxy service

After creating a sample WSDL proxy service, the user can add one or more BAM mediators to the sequence of WSDL Proxy Service as follows.

  1. Go to the ESB's management console and select Main > Axis2 Services > List menu.
  2. Click on Simple_Stock_Quote_Service_Proxy to go to its dashboard.
  3. Click Edit under category Specific Configuration and then click Next.
  4. Select option Define Inline under category Define In Sequence and then click the Create link associated with it.
  5. Click on Configuration Registry link, select [Sequence]-fault from the drop down list and click OK.
  6. Click on Add Child link on the Root, select Agent > BAM from menus.
  7. Select BAM element from the sequence tree.
  8. In the form that appears, select a Server Profile and a Stream Name from the available lists. Similarly, select a Stream Version. For example,
  9. Click Update. You can view the mediator XML generated for the BAM Mediator by selecting the switch to source view option. To go back to the design view, click switch to design view. Given below is an example how the mediator XML looks:

    Code Block
    languagehtml/xml
    <bam xmlns="http://ws.apache.org/ns/synapse">
       <serverProfile name="profile1">
          <streamConfig name="stream1" version="1.0.0" ></streamConfig>
       </serverProfile>
    </bam>
  10. Click Save, then Next and then Finish.

The BAM mediator is now added to the WSDL proxy service named Simple_Stock_Quote_Service_Proxy.

Sending messages from the ESB 
Anchor
Sending Messages to ESB
Sending Messages to ESB

Before you test the BAM mediator, finish all steps discussed above. In this section, we send custom messages through the WSDL proxy service created earlier and test whether they are correctly stored in a Cassandra database. This is an example, but the same steps apply in any a production scenario, using any Thrift listening port.

  1. Download and start WSO2 BAM. Be sure to use a port different to WSO2 ESB to avoid any port conflicts (at this point, WSO2 ESB must be downloaded and started).
  2. Go to <ESB_HOME>/samples/axis2Client and build the backend service with Apache Ant as follows:
    ant stockquote -Daddurl=https://localhost:8244/services/Simple_Stock_Quote_Service_Proxy -Dmode=fullquote -Dsymbol=testString
    

    NOTE: addurl value must be given from the HTTPS endpoint located in Simple_Stock_Quote_Service_Proxy's service dashboard. To see the dashboard, go to the ESB management console, select Main > Web Services > List menu and select Simple_Stock_Quote_Service_Proxy. You can use a preferred string instead of testString for symbol.

    Check if the BAM mediator in Simple_Stock_Quote_Service_Proxy has dumped data extracted from the ESB to the key-space EVENT_KS in the Cassandra database, with the column family name same as the Stream Name. To view data in the Cassandra database, see the Cassandra Explorer in the BAM server. Given below is an example screenshot: