[Download] | [Documentation Home] | [Release Note]
Introduction
WSO2 Data Services Server provides the capability of exposing data from a Cassandra data-source as a service. This guide will explain how a Data Service can be created using a Cassandra data-source.
NOTE: WSO2DSS-3.1.0 has inbuilt support for Cassandra server versions 1.2.5 or later. If you need to use Cassandra server versions older than 1.2.5, then you need to uninstall the cassandra-jdbc-1.2.5 feature using 'Feature Management' and install the cassandra-jdbc-1.1.1/cassandra-jdbc-1.0.5 feature.
Let's begin by creating a simple keyspace add some column family to work with. Here is the Cassandra-cli commands to perform this tasks.
Step 1: Create Keyspace and Column Family
create keyspace Keyspace1;
use Keyspace1;
create column family USER with comparator=UTF8Type and key_validation_class=UTF8Type
and column_metadata=[{column_name: user_id, validation_class: UTF8Type, index_type: KEYS},
{column_name: username, validation_class: UTF8Type},
{column_name: password, validation_class: UTF8Type}];
set USER[user1][username]='dinusha';
set USER[user1][password]='mypwd';
Step 2: Start by giving a name
Lets begin to create the data service by clicking on the 'Create' link in left menu . It requires to enter a name to the Data service. Lets name it as CassandraSampleService and click on Next.
Figure 1: Create Data Service
Step 3: Enter details about your Cassandra data-source
Next step is to enter details about the data-source which we are using to create the service. Select the Data Source Type as "Cassandra" from the drop down list after you giving a name to the data source.
Figure 2: Configure Cassandra data-source
Created data source will list and click on "Next" to create the query.
Step 4: Create Query
To extract information you need to create a query along with the structure of the response.
Give a name to the query, and select the data source name from the drop down, which is created in previous step. Specify the CQL query and parameters. Save the query once you enter the details.
Figure 3: Create New Query
Click on "Add Output Mapping" button to create how the output should look like. Once you have entered the output mapping details click on "Main Configuration" and click on "Save" button.
Figure 4: Add Output Mappings
Created query will be listed as follows. Click on "Next" to create the operation.
Step 5: Create a web service operation
Enter a name for the operation and select the query from the drop down list. Click on "Save".
Figure 5: Add operation
Once you click on "Finish" your data service will be created and deployed.
Step 6: Service deployed
You can see the deployed service by clicking on "List" under Main/List left menu. Deployed CassandraSampleService service will be list as follows.
Figure 6: Deployed Services
Click on the "CassandraSampleService". It will direct to the Service Dashboard. You can click on "Edit Data Service (XML Edit)" and view the created data service as a XML.
Figure 7: Edit data service
Step 7: Try your service
Click on "Try It" link to invoke the service.
Figure 8: Invoke service using Try-it