Cassandra Sample
Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:
<PRODUCT_HOME>/
repository/samples/
 directory that includes all Data Integration samples is changed toÂ<EI_HOME>/
samples/data-services/
.<PRODUCT_HOME>/
repository/samples/resources/
 directory that includes all artifacts related to the Data Integration samples is changed toÂ<EI_HOME>/
samples/data-services/resources/
.
This sample demonstrates the use of the Cassandra data source functionality in WSO2 Enterprise Integrator (WSO2 EI), which you can use to connect to a Cassandra cluster.
Prerequisites
A Cassandra server of version 1.2.x, 2.0 or 3.0 should be already running in the default port. Cassandra version 3.0 is recommended. For instructions, go to Apache Cassandra Documentation.
Building the sample
The sample named CassandraSample is shipped with WSO2 EI, by default. This .dbs file is stored in the <EI_HOME>/samples/data-services/dbs/cassandra/
 directory. Follow the steps given below.
- Before you upload the sample data service, be sure to start the Cassandra server.
- Follow the instructions in Uploading a Created Data to deploy the sample file (CassandraSample.dbs) in the ESB of WSO2 EI. Click Services → List on the navigator. The sample should be listed on the services' dashboard.
For more information on using Cassandra as a datasource, see this tutorial.
Running the sample
The sample service can be run using the TryIt tool, which is bundled with the WSO2 EI. Follow the steps below to demonstrate this functionality using the TryIt tool:
- Log in to the management console of your server and click List under Services in the navigator. The CassandraSample will be listed here.
- Click Try this service to open the TryIt tool.Â
- The service contains the following operations:Â
- "createKS": This creates the Cassandra keyspace required for the sample. This must be called once before running other operations.
- "createTable": This creates a Cassandra CQL3 table required for the sample. This must be called once after "createKS" is called.
- "addUser": This operation takes in user details and adds it to Cassandra. Here "ID" is the primary key and it takes in an UUID as the value.
- "addUser_batch_req": This is the corresponding batch request of "addUser", where it takes in a batch of "addUser" data entries and adds it as a single batch operation.
- "getUserById": This operation returns the user information when you provide the ID of a specific user.
- "getUsers": This operation returns information of all the users stored in the Cassandra store.