Configuring WSO2 BAM 2.4.1 with external Apache Cassandra 2.x cluster

WSO2 Business Activity Monitor (BAM) writes incoming data(events) into Cassandra. Reason why Cassandra came into play is it’s higher write throughput, linear scalability and eventual consistency.
By default, BAM ships with an embedded Cassandra instance which starts and stops with BAM. But when running on a production environment, single Cassandra instance will not be capable of handling higher data load. So BAM can be configured to work with an external Cassandra cluster which is highly available and scalable.

Instructions for setting up a multi node Cassandra cluster can be found at [1].
WSO2 BAM 2.4.1 can be downloaded from [2]

Purpose of this post is to demonstrate how WSO2 BAM 2.4.1 instance can be configured to work with a cluster of three Apache Cassandra 2.x nodes.
Note: Same instructions applies when configuring BAM with Apache Cassandra 1.x

Let’s assume hostnames and ports of the Cassandra ring are as follows.
– 192.168.0.1 on port 9160
– 192.168.0.2 on port 9160
– 192.168.0.3 on port 9160

BAM_241_Cassandra

Step 1: Edit <BAM installation folder>/repository/conf/etc/hector-config.xml

This file configures the nodes which belongs to Cassandra cluster/ring. Incoming event data will be written to these nodes.
Edit hector-config.xml to include the nodes of our Cassandra ring as follows.

<HectorConfiguration>
 <Cluster>
   <Name>ClusterOne</Name>

   <Nodes>192.168.0.1:9160,192.168.0.2:9160,192.168.0.3:9160</Nodes>

   <AutoDiscovery disable="false" delay="1000"/>
 </Cluster>
</HectorConfiguration>

Note: For BAM versions before 2.4.1, this configuration lies inside   <BAM installation folder>/repository/conf/etc/cassandra-component.xml

Step 2:  Edit <BAM installation folder>/repository/conf/datasources/bam-datasources.xml

This file configures the Cassandra datasources. Simply put, nodes where BAM reads data from Cassandra.

WSO2BAM_CASSANDRA_DATASOURCE configuration.

Make sure to put correct Cassandra credentials for <username> and <passwords>.

<datasource>
 <name>WSO2BAM_CASSANDRA_DATASOURCE</name>
 <description>The datasource used for Cassandra data</description>
 <definition type="RDBMS">
 <configuration>
 <url>jdbc:cassandra://192.168.0.1:9160/EVENT_KS,jdbc:cassandra://192.168.0.2:9160/EVENT_KS,jdbc:cassandra://192.168.0.3:9160/EVENT_KS</url>
 <username>admin</username>
 <password>admin</password>
 </configuration>
 </definition>
 </datasource>

WSO2BAM_UTIL_DATASOURCE configuration.

Make sure to put correct Cassandra credentials for <username> and <passwords>. Most importantly set externalCassandra flag to true.

<datasource>
 <name>WSO2BAM_UTIL_DATASOURCE</name>
 <description>The datasource used for BAM utilities, such as message store etc..</description>
 <definition type="RDBMS">
 <configuration>
 <url>jdbc:cassandra://192.168.0.1:9160/EVENT_KS,jdbc:cassandra://192.168.0.2:9160/EVENT_KS,jdbc:cassandra://192.168.0.3:9160/EVENT_KS</url>
 <username>admin</username>
 <password>admin</password>
 <dataSourceProps>
 <property name="externalCassandra">true</property>
 </dataSourceProps>
 </configuration>
 </definition>
 </datasource>

Note: For BAM versions before 2.4.1, these configurations can be found inside   <BAM installation folder>/repository/conf/datasources/master-datasources.xml

Step 3:  Edit <BAM installation folder>/repository/conf/advanced/streamdefn.xml

This file configures the replication factor and read/write consistency levels for data receivers when writing data to Cassandra.

Edit <ReplicationFactor>, <ReadConsistencyLevel> and <WriteConsistencyLevel> as follows.

<StreamDefinition>
 <NodeId>1</NodeId>
<keySpaceName>EVENT_KS</keySpaceName>
<eventIndexKeySpaceName>EVENT_INDEX_KS</eventIndexKeySpaceName>
<ReplicationFactor>3</ReplicationFactor>
<ReadConsistencyLevel>QUORUM</ReadConsistencyLevel>
<WriteConsistencyLevel>ONE</WriteConsistencyLevel>
<StrategyClass>org.apache.cassandra.locator.SimpleStrategy</StrategyClass></StreamDefinition>

 

That’s it. Now your BAM instance is all set to go. Once it receives data, they will be written into the external Cassandra ring.

[1] http://www.datastax.com/documentation/cassandra/2.0/cassandra/initialize/initializeSingleDS.html

[2] http://wso2.com/products/business-activity-monitor/

Advertisements

One thought on “Configuring WSO2 BAM 2.4.1 with external Apache Cassandra 2.x cluster

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s