Camel-Gora is an Apache Camel component that allows you to work with NoSQL databases using the Apache Gora framework.
N.B. Camel-Gora is NOT a Gora module... but instead a Camel one. This documentation exists to provide detail on how Gora is being used in different settings.
Available as of Camel 2.14
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>
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"/>
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.
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.* |
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.* |
Property | Type | Description |
---|---|---|
keyClass
| _String_ | *Key type.* * |
valueClass
| _String_ | *Value type.* * |
dataStoreClass
| _String_ | *DataStore type* * |
hadoopConfiguration
| _Configuration_ | *Hadoop Configuration* |
concurrentConsumers
| _int_ | *Concurrent Consumers (used only by consumers).* |
flushOnEveryOperation
| _boolean_ | *Flush on every operation (used only by producers).* |
NOTE: the gora configuration properties marked with asterisk are mandatory
Property | Type | Description |
---|---|---|
startTime
| _long_ | *Start Time attribute.* |
endTime
| _long_ | *End Time attribute.* |
timeRangeFrom
| _long_ | *Time Range From attribute.* |
timeRangeTo
| _long_ | *Time Range To attribute.* |
limit
| _long_ | *Gora Query Limit attribute.* |
timestamp
| _long_ | *Timestamp attribute.* |
startKey
| _Object_ | *Start Key attribute.* |
endKey
| _Object_ | *End Key attribute.* |
keyRangeFrom
| _Object_ | *Key Range From attribute.* |
keyRangeTo
| _Object_ | *Key Range To attribute.* |
fields
| _String_ | *Fields attribute.* |
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.
For more please information and in depth configuration refer to the Apache Gora Documentation and the Apache Gora Tutorial.