Skip to content

Instantly share code, notes, and snippets.

@johndemic
Created October 5, 2012 17:11
Show Gist options
  • Save johndemic/3841064 to your computer and use it in GitHub Desktop.
Save johndemic/3841064 to your computer and use it in GitHub Desktop.
Directory Implementation with Mule and Cassandra
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:cassandradb="http://www.mulesoft.org/schema/mule/cassandradb" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/cassandradb http://www.mulesoft.org/schema/mule/cassandradb/3.2/mule-cassandradb.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd ">
<cassandradb:config name="CassandraDB"
host="localhost"
keyspace="Account"
doc:name="Cassandradb"/>
<flow name="AccountCreate" doc:name="AccountsCreate">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" path="account/create" method="POST" mimeType="application/json" />
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Map"/>
<cassandradb:insert config-ref="CassandraDB" doc:name="Cassandra Insert"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
<flow name="AccountList" doc:name="AccountsList">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="account/list" doc:name="HTTP"/>
<cassandradb:get-slice config-ref="CassandraDB" rowKey="#[message.inboundProperties['http.relative.path'].split('/')[0]]" columnParent="Accounts" count="100"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
<flow name="AccountGet" doc:name="AccountGet">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="account/get" doc:name="HTTP"/>
<cassandradb:get config-ref="CassandraDB" columnPath="Accounts:#[message.inboundProperties['http.relative.path'].split('/')[1]]"
rowKey="#[message.inboundProperties['http.relative.path'].split('/')[0]]" doc:name="Cassandradb"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
<flow name="AccountDelete" doc:name="AccountGet">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="account/delete" doc:name="HTTP"/>
<cassandradb:remove config-ref="CassandraDB" columnPath="Accounts:#[message.inboundProperties['http.relative.path'].split('/')[1]]"
rowKey="#[message.inboundProperties['http.relative.path'].split('/')[0]]" doc:name="Cassandradb"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
</mule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment