The "Cassandra Server" feature, which is based on WSO2 Carbon 4.0.0 onwards, provides in-built support to expose data from a Cassandra data-source (versions 1.1.0 or later) as a service. This feature is listed as follows in the WSO2 feature repository.
Name : Cassandra-JDBC-1.1.1 server Feature
Identifier : org.wso2.carbon.cassandra-jdbc-1.1.1.server.feature.group
If you need to use Cassandra server versions older than 1.1.0, uninstall the above feature according to the instruction given in section Feature Management and install the "cassandra-jdbc-1.0.5" feature from the feature repository.
Follow the instructions below to expose data in the Cassandra database as services.
1. First, create a simple keyspace and add some columns to work with. Here are the Cassandra-cli commands to perform this tasks:
1. Log on to the product's management console and select "Data Service -> Create" under the "Main" menu.
2. The "Create Data Service" page appears. Fill in the fields and click "Next" . The Data Service name is mandatory.
For more information on advanced configurations, refer to Advanced Data Service Configurations.
3. The "Data Sources" page appears. Click on the "Add New Data Source" link and add your Data Source details. Then click "Save" .
For a Cassandra data source, select the data source type as "Cassandra ". For example,
Before saving, you can click on the 'Test Connection' button. If the database connection is successful, you will get a 'connection is successful' message:
4. After saving, the added data source page appears. You can edit or delete the Data Source. To proceed click "Next" .
5. The "Queries" page appears. Initially your service does not include any queries. Click on 'Add New Query' to add a new query, input/output mappings, events etc. to your Data Service.
To extract information you need to create a query relevant to the structure of the response. Give a name to the query, and select the data source which was created in the previous step. Specify the CQL query and parameters and click "Save" . For example,
Query ID : getUsers
Data Source : CassandraDatasource
CQL : select 'key', 'username', 'password' from USER
To define how the output looks like, click the "Add Output Mapping" button. For example,
For information on adding validations to your input mappings, refer to section Input Validators . Also, detailed information on writing queries can be found in section Data Service Queries. Once you have entered the mapping details, click on "Main Configuration" and then the "Save" button.
6. You have added one query to your data service configuration. You can edit or delete your query. To continue, click "Next ".
7. The "Operations" page appear s. Click the "Add new operation" link to c reate an operation. Select a query to be executed when this operation is called. For example,
Click "Save" once done.
8. The Data Service configuration is done. Click "Finish" . ( You can continue to add resources by clicking the "Next" button if you like)
9. You will be navigated to the "Deployed Services" page where the data service is listed .
From here, you can manage your data service. For instructions, refer to section Managing Data Services.