In this post I hope to explain how you can configure WSO2 CEP to store events in Apache Cassandra.This don't intent to describe how you can configure WSO2 CEP to receive events . Hence, I'm using configurations of sample 0001 and extend it to publish events to Cassandra as well in addition to publishing as WSO2Event*
- CEP receives events as WSO2Events
- Store received events in Cassandra.
For the sake of simplicity there's no any processing done and events are just passed through.
*WSO2Event is a Thrift based format for events supported by WSO2 CEP.
Configuring WSO2 CEP Server1. Bring up CEP server with sample configuration 0001 by executing following command in <CEP_HOME>/bin,
./wso2cep-samples.sh -sn 0001 -Ddisable.cassandra.server.startup=false
By setting disable.cassandra.server.startup=false we bring up the embedded Cassandra in CEP server and event's will be stored in it. But, note that this embedded cassandra is only to be used for testing purposes and it's recommended to DISABLE IN PRODUCTION deployments.
2. Add an Cassandra output event Adaptor by navigating to "Configure" -> "Output Event Adaptors". Output adaptor is the component which communicate with Cassandra server and carry out the transport.
Note that I have configured the output adaptor to connect to embedded Cassandra server @ localhost:9160 and used both user name and password as "admin"
3. Create an event formatter using the "CassandraOutoutEventAdaptor" by navigating to "Event Streams" -> "OutFlows" of org.wso2.sample.service.data:1.0.0 stream.
Event builder is the component which converts the outbound events to a format which can be stored in Cassandra. Here you have to enter keyspace name and column family name to be used when storing events in Cassandra.
Only 'map' "Output Event Type" can be used with Cassandra, it will map value of each attribute in an event to key value pairs. Please refer  for more on map event formatters.
Now you have configured CEP server to store/publish events to Cassandra.
Verifying if it worksTo verify if events have really stored in Cassandra server let's use "cassandra-cli".
1. Login to Cassandra server with using user name and password as "admin".
./cassandra-cli -u admin -pw admin
LIST TestEventColumnFamily; <- Listing all rows in the KeyspaceIf events are successfully stored something similar to following should be shown.
References - Output cassandra event adaptor - WSO2 CEP Documentation
 - https://docs.wso2.com/display/CEP310/Map+Event+Formatter