This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Exposing Cassandra as a Data Service
This tutorial will guide you on how to expose data stored in Cassandra as a data service. Also, see the samples in Data Integration Samples.
Install and start Cassandra
A Cassandra server of version 3.0 should be already running in the default port. For instructions, go to Apache Cassandra Documentation.
Adding a Cassandra datasource
Now, let's start creating the data service from scratch:
Log in to the management console using the following URL on your browser: https://localhost:9443/carbon/.
Click Create under the Data Service menu to open the Create Data Service wizard.
In the Create Data Service screen, enter Cassandra as the data service name.
Click Next to go to the Add New Data Source screen.
Select Cassandra as the data source type. The Cassandra-specific options will be available for editing.
See the following links for setting up Cassandra as a data store:
- Get familiar with the basics of Cassandra, including the prerequisites for using Cassandra, by going through the following: https://wiki.apache.org/cassandra/GettingStarted.
- Get familiar with using the Cassandra CLI, by going through the following: http://wiki.apache.org/cassandra/CassandraCli.
- Functionality of the underlying connector used for the Cassandra datasource: https://www.datastax.com/documentation/developer/java-driver/2.0/index.html.
- Also, note that Cassandra requires the most stable version of Java 7 or 8 you can deploy; preferably the Oracle/Sun JVM.
Define a query for the datasource
Now let's start writing a query for getting data from the datasource. The query will specify the data that should be fetched by this query, and the format that should be used to display data when the query is invoked.
- Click Add New Query to open the Add New Query screen.
- Enter the following values:
- Query ID: Enter an ID for the query.
- Datasource: Select the datasource for which you are going to write a query. Select the Cassandra datasource that you created previously.
SQL: In this field, enter the SQL statement describing the data that should be retrieved from the Cassandra datasource.
Add input mappings: Input mappings allow you to add parameters to a query so that you can set the parameter value when executing the query.
Find out more about defining Input Mappings.
Add output mappings: Out mapping is used to specify how the data that is fetched from your query will be shown in the response.
Find out more about defining Output Mappings.
- Click Next to open the Operations screen.
Define operation to invoke the query
Follow the steps given below.
- Click Add New Operation to open Add New Operation screen.
- Add a name for your operation in the Operation Name field.
- In the Query ID field, select the query that you defined previously.
- Save the operation.
Finish creating the data service
In this tutorial, we are only defining a SOAP service to expose the data. Therefore, you can click Finish to complete the data service creation process, after defining the operation. You will now be taken to the Deployed Services screen, which shows all the data services deployed on the server.
If you click Next after defining the operation, you will be taken to the Add Resources screen, which allows you to expose the data as a REST resource. If you want to create a REST resource, see Exposing Data as a REST Resource for information.
Samples
For a sample, which exposes Cassandra as a data service, see Cassandra Sample.