CassandraDB Connector


The Anypoint Connector for Apache Cassandra allows Mule applications to access the data in Apache Cassandra database instances.

This document describes implementation examples using Anypoint Studio and includes configuration details for using the XML Editor.


This document assumes that you are familiar with Mule, Anypoint Connectors, and the Anypoint Studio Essentials. To increase your familiarity with Studio, consider completing one or more Anypoint Studio Tutorials.

Installing Cassandra Connector in Anypoint Studio

You can "test drive" the CassandraDB connector by installing it in Anypoint Studio. Follow the instructions to Download and Launch Anypoint Studio, then follow the steps below to install the CassandraDB connector.

To install the Cassandra connector in Anypoint Studio:

  1. Under the Help menu in Anypoint Studio, select Install New Software.

  2. In the Install menu, click the drop-down arrow for Work with, and click Anypoint Connectors Update Site.

  3. In the table below the Filter field, click the right arrow to expand the Community folder, and click CassandraDB Connector (Mule 3.5+). Click Next.

  4. Review the details of the item you selected, then click Next.

  5. Click to accept terms and conditions of the product, then click Finish.

  6. Click Restart Now to complete the installation. After you have install the connector and restart Studio, several new message processors appear in the palette under the Connectors category.

Configuring the Cassandra Connector

To use the CassandraDB connector in your Mule application, you must configure:

  • A global CassandraDB element for use by all the CassandraDB connectors in an application. For more information, see Mule Global Elements.

  • Parameters of each CassandraDB connector instance in the application.

Follow these steps to configure CassandraDB connector in a Mule application:

Studio Visual Editor

  1. Click the Global Elements tab at the base of the canvas, then click Create.

  2. In the Choose Global Type menu, use the filter to locate and select CassandraDB, then click OK.

  3. Configure the parameters according to the table below.

    Parameter Description


    Enter a name for the configuration so it can be referenced later by the config-ref parameter in the flow.


    Enter a Cassandra username. Use a dummy username if you have disabled authentication.


    Enter the password. Leave this field empty if you have disabled authentication.


    Enter host name or IP address of the application.


    Enter a port number. The default port is 9160.


    Enter the Cassandra keyspace. A keyspace groups column families together.

    Consistency Level

    Specify the number of replicas that need to respond to a read request before returning data to an application. ONE is the default.

  4. Access the Pooling Profile tab to configure any settings relevant to managing multiple connections using a connection pool.

  5. Access the Reconnection tab to configure any settings relevant to reconnection strategies that Mule should execute if it loses its connection to Cassandra.

  6. Click OK to save the global connector configurations.

  7. Return to the Message Flow tab in Studio.

Configuration in a Flow

Follow these steps to configure the parameters of the CassandraDB connector in the flow:

  1. Drag the CassandraDB connector onto the canvas, then select it to open the Properties Editor console.

  2. Configure these connector parameters:

    Field Description Default

    Display Name

    Enter a unique label for the connector in your application.

    Cassandra DB

    Connector Configuration

    Connect to a global element linked to this connector. Global elements encapsulate reusable data about the connection to the target resource or service. Select the global CassandraDB connector element that you just created.



    Select the action this component must perform.


  3. Save your configurations.

XML Editor

Include the CassandraDB namespaces in your configuration file:

<mule xmlns=""

      <!-- Your flows and configuration elements -->


Follow these steps to configure a CassandraDB connector in your application:

  1. Create a global CassandraDB configuration outside and above your flows, using this global configuration code:

<!-- Simple configuration -->
<cassandradb:config name="Cassandradb" username="Your Cassandra username" keyspace="<Your Cassandra keyspace" doc:name="Cassandradb"/>

Build your application flow, then add a CassandraDB connector using one of the following operations.

The following table provides details on each operation:

Operation Description


Increments a CounterColumn consisting of (name, value) at the given ColumnParent.


Executes the specified batch mutations on the keyspace.


Gets the name of the cluster.


Gets information about the specified keyspace.


Gets a list of all the keyspaces configured for the cluster.


Gets the name of the partitioner for the cluster.


Gets the token ring; a map of ranges to host addresses.


Returns a list of nodes per version for each schema version present in a cluster.


Gets the name of the snitch used for the cluster. A snitch indicates which datacenter and rack that data is written to and from.


Gets the Thrift API version.


Executes a CQL (Cassandra Query Language) statement and returns a CqlResult containing the results.


Gets Column or SuperColumn by the path.


Counts the columns present in column_parent within the predicate.


Returns a list of slices, but uses IndexClause instead of KeyRange.


Replaces get_range_slices.


Gets Column or SuperColumn by the path.


Gets the group of columns contained by column_parent (either a ColumnFamily name or a ColumnFamily and SuperColumn name pair) specified by the given SlicePredicate (start, finish, reversed and count) parameters.


Inserts a Column consisting of name, value, timestamp, and ttl (time to live) for a ColumnParent.


Inserts an object into the database.


Provides a combination of multiget_slice and get_count.


Retrieves slices for column_parent and predicate on each of the given keys in parallel.


Removes data from a row specified by a key at the granularity specified by column_path, and the given timestamp.


Removes a counter from the row specified by a key at the granularity specified by column_path.


Sets the keyspace to use for subsequent requests.


Adds a column family from an object.


Adds a column family from an object that has a simple name.


Adds a column family to the current keyspace.


Creates a new keyspace and any column families defined with it.


Creates a new keyspace with the provided name with all the defaults values


Drops a column family.


Drops a keyspace.


Updates properties of a ColumnFamily.


Updates properties of a keyspace.


Removes all the rows from a column family.

Example Use Case

Adds a new keyspace in the Apache Cassandra database with default values. A keyspace groups column families together.


Studio Visual Editor

  1. Drag an HTTP endpoint into a new flow , and configure it as follows:

  2. Drag the CassandraDB connector onto the canvas, then select it to open the properties editor console.

  3. Click the + sign next to the Connector Configuration field to add a new global connector configuration:

  4. Configure the global element:

    Field Value


    CassandraDB (or any other name you prefer)


    <Your Cassandra username> (You can use a dummy username if you disabled authentication)


    <Your Cassandra password> ( You can leave this element blank if you disabled authentication)




    9160 (default is 9160)


    <Cassandra Keyspace>

    Consistency Level

    ONE (default)

  5. In the properties editor of the CassandraDB connector, configure the remaining parameters:

    Field Value

    Display Name

    Add-Keyspace (or any other name you prefer)

    Connector * *Configuration

    CassandraDB (name of the global element you have created)


    System adds a keyspace with parameters

    Keyspace Name


  6. Run the project as a Mule Application (right-click project name, then select Run As > Mule Application).

  7. From a browser, navigate to` http://localhost:8081/?keyspace=`<keyspacename> .Mule conducts the query, and creates the CassandraDB keyspace with the specified name.

  8. Add a cassandradb:config element to your project, then configure its attributes according to the table below.

XML Editor

  1. Add a cassandradb:config element to your project, then configure its attributes according to the table below.

    <cassandradb:config name="Cassandradb" username="dummy"  keyspace="system" doc:name="Cassandradb"/>
    Attribute Value






    <Your Cassandra username>



  2. Create a Mule flow with an HTTP endpoint, configuring the endpoint according to the table below.

    <http:inbound-endpoint exchange-pattern="request-response"
    host="localhost" port="8090" path="cassandra/addKeyspace"
    Attribute Value











  3. Add a cassandradb:system-add-keyspace-with-params element to your flow, configuring the attributes according to the table below.

    <cassandradb:system-add-keyspace-with-params config-ref="Cassandradb" keyspaceName="#[message.inboundProperties['keyspace']]"  doc:name="Add-Keyspace">
    Attribute Value







  4. Run the project as a Mule Application (right-click project name, then select Run As > Mule Application).

  5. From a browser, navigate to` http://localhost:8081/?keyspace= `<keyspacename>

  6. Mule conducts the query, and adds the keyspace with the specified name.

Example Code

<mule xmlns:scripting="" xmlns:mulexml="" xmlns:json="" xmlns:cassandradb="" xmlns:http="" xmlns:tracking="" xmlns="" xmlns:doc="" xmlns:spring="" xmlns:xsi="" xsi:schemaLocation="">
    <cassandradb:config name="Cassandradb" username="dummy" keyspace="system" doc:name="Cassandradb"/>
    <cassandradb:config name="CassandradbNuevo" username="dummy"  keyspace="NewUserKeyspace" doc:name="Cassandradb"/>
    <flow name="AddKeyspace" doc:name="AddKeyspace">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="cassandra/addKeyspace" doc:name="HTTP"/>
        <cassandradb:system-add-keyspace-with-params config-ref="Cassandradb" keyspaceName="#[message.inboundProperties['keyspace']]" doc:name="Add-Keyspace">
        <set-payload value="New keyspaces #[message.inboundProperties['keyspace']] was added. New schema key #[payload]" doc:name="Set Payload"/>
    <flow name="Batch-mutable" doc:name="Batch-mutable">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
        <cassandradb:add config-ref="" doc:name="Cassandradb" columnParent="" counterName="" counterValue="" rowKey=""/>

Note: In this code example, spring-beans-current.xsd is a placeholder. To locate the correct version, see