Gora
Since Camel 2.14
Camel-Gora is an Apache Camel component that allows you to work with NoSQL databases using the Apache Gora framework.
Maven users will need to add the following dependency to their pom.xml for this component:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-gora</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
Apache Gora Overview
The Apache Gora open source framework provides an in-memory data model and persistence for big data. Gora supports persisting to column stores, key value stores, document stores and RDBMSs, and analyzing the data with extensive Apache Hadoop™ MapReduce support. Gora uses the Apache Software License v2.0 and graduated from the Apache Incubator in Janauary 2012 to become a top-level Apache project.
Apache Gora currently supports the following datastores: Apache HBase, Apache Cassandra, Apache Accumulo, Amazon DynamoDB and SQL databases such as hsqldb, MySQL and more.
URI format
gora:instanceName[?options]
Hbase examples with mandatory options :
XML
<to uri="gora:foobar?keyClass=java.lang.Long&valueClass=org.apache.camel.component.gora.generated.Pageview&dataStoreClass=org.apache.gora.hbase.store.HBaseStore"/>
Java DSL
to("gora:foobar?keyClass=java.lang.Long&valueClass=org.apache.camel.component.gora.generated.Pageview&dataStoreClass=org.apache.gora.hbase.store.HBaseStore")
Configuratiion
Using camel-gora needs some configuration. This mainly involve to configure the AvroStore through the gora.properties file and to define the relevant mappings as part of the gora-core module.
Extensive information for this configuration can be found in the apache gora documentation and the gora-conf page.
Options
The Gora component has no options.
The Gora endpoint is configured using URI syntax:
gora:name
with the following path and query parameters:
Query Parameters (21 parameters):
Name | Description | Default | Type |
---|---|---|---|
dataStoreClass (common) |
The type of the dataStore |
String |
|
keyClass (common) |
The type class of the key |
String |
|
valueClass (common) |
The type of the value |
String |
|
bridgeErrorHandler (consumer) |
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. |
false |
boolean |
concurrentConsumers (consumer) |
Number of concurrent consumers |
1 |
int |
endKey (consumer) |
The End Key |
Object |
|
endTime (consumer) |
The End Time |
long |
|
fields (consumer) |
The Fields |
Strings |
|
keyRangeFrom (consumer) |
The Key Range From |
Object |
|
keyRangeTo (consumer) |
The Key Range To |
Object |
|
limit (consumer) |
The Limit |
long |
|
startKey (consumer) |
The Start Key |
Object |
|
startTime (consumer) |
The Start Time |
long |
|
timeRangeFrom (consumer) |
The Time Range From |
long |
|
timeRangeTo (consumer) |
The Time Range To |
long |
|
timestamp (consumer) |
The Timestamp |
long |
|
exceptionHandler (consumer) |
To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |
ExceptionHandler |
|
exchangePattern (consumer) |
Sets the exchange pattern when the consumer creates an exchange. |
ExchangePattern |
|
flushOnEveryOperation (producer) |
Flush on every operation |
true |
boolean |
hadoopConfiguration (advanced) |
Hadoop Configuration |
Configuration |
|
synchronous (advanced) |
Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). |
false |
boolean |
Spring Boot Auto-Configuration
When using Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-gora-starter</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
The component supports 2 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
camel.component.gora.enabled |
Enable gora component |
true |
Boolean |
camel.component.gora.resolve-property-placeholders |
Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. |
true |
Boolean |
Supported Gora Operations
Supported operations include : put, get, delete, getSchemaName, deleteSchema, createSchema, query, deleteByQuery, schemaExists.
Some of the operations require arguments while some others no. The arguments to operations could be either the body of the in message or defined in a header property. Below there is a list with some additional info for each operation.
Property | Description |
---|---|
put |
Inserts the persistent object with the given key. |
get |
Returns the object corresponding to the given key fetching all the fields. |
delete |
Deletes the object with the given key. |
getSchemaName |
Returns the schema name given to this DataStore. |
deleteSchema |
Deletes the underlying schema or table (or similar) in the datastore that holds the objects. |
createSchema |
Creates the optional schema or table (or similar) in the datastore to hold the objects. |
query |
Executes the given query and returns the results. |
deleteByQuery |
Deletes all the objects matching the query. |
schemaExists |
Returns whether the schema that holds the data exists in the datastore. |
Gora Headers
Property | Description |
---|---|
GoraOperation |
Used in order to define the operation to execute. |
GoraKey |
Used in order to define the datum key for the operations need it. |
Usage examples
Create Schema (XML DSL):
<setHeader headerName="GoraOperation">
<constant>CreateSchema</constant>
</setHeader>
<to uri="gora:foobar?keyClass=java.lang.Long&valueClass=org.apache.camel.component.gora.generated.Pageview&dataStoreClass=org.apache.gora.hbase.store.HBaseStore"/>
SchemaExists (XML DSL):
<setHeader headerName="GoraOperation">
<constant>SchemaExists</constant>
</setHeader>
<to uri="gora:foobar?keyClass=java.lang.Long&valueClass=org.apache.camel.component.gora.generated.Pageview&dataStoreClass=org.apache.gora.hbase.store.HBaseStore"/>
Put (XML DSL):
<setHeader headerName="GoraOperation">
<constant>put</constant>
</setHeader>
<setHeader headerName="GoraKey">
<constant>22222</constant>
</setHeader>
<to uri="gora:foo?keyClass=java.lang.Long&valueClass=org.apache.camel.component.gora.generated.Pageview&dataStoreClass=org.apache.gora.hbase.store.HBaseStore"/>
Get (XML DSL):
<setHeader headerName="GoraOperation">
<constant>GET</constant>
</setHeader>
<setHeader headerName="GoraKey">
<constant>10101</constant>
</setHeader>
<to uri="gora:bar?keyClass=java.lang.Long&valueClass=org.apache.camel.component.gora.generated.Pageview&dataStoreClass=org.apache.gora.hbase.store.HBaseStore"/>
Delete (XML DSL):
<setHeader headerName="GoraOperation">
<constant>DELETE</constant>
</setHeader>
<setHeader headerName="GoraKey">
<constant>22222</constant>
</setHeader>
<to uri="gora:bar?keyClass=java.lang.Long&valueClass=org.apache.camel.component.gora.generated.Pageview&dataStoreClass=org.apache.gora.hbase.store.HBaseStore"/>
Query (XML DSL):
<to uri="gora:foobar?keyClass=java.lang.Long&valueClass=org.apache.camel.component.gora.generated.Pageview&dataStoreClass=org.apache.gora.hbase.store.HBaseStore"/>
The full usage examples in the form of integration tests can be found at camel-gora-examples repository.
More resources
For more please information and in depth configuration refer to the Apache Gora Documentation and the Apache Gora Tutorial.