ArangoDb

Since Camel 3.5

Only producer is supported

The ArangoDb component is a ArangoDb client that uses the arango java driver to perform queries on collections and graphs in the ArangoDb database.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-arangodb</artifactId>
    <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

URI format

arangodb:database[?options]

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

The component level is the highest level which holds general and common configurations that are inherited by the endpoints. For example a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

Configuring components can be done with the Component DSL, in a configuration file (application.properties|yaml), or directly with Java code.

Configuring Endpoint Options

Where you find yourself configuring the most is on endpoints, as endpoints often have many options, which allows you to configure what you need the endpoint to do. The options are also categorized into whether the endpoint is used as consumer (from) or as a producer (to), or used for both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL as a type safe way of configuring endpoints.

A good practice when configuring options is to use Property Placeholders, which allows to not hardcode urls, port numbers, sensitive information, and other settings. In other words placeholders allows to externalize the configuration from your code, and gives more flexibility and reuse.

The following two sections lists all the options, firstly for the component followed by the endpoint.

Component Options

The ArangoDb component supports 12 options, which are listed below.

Name Description Default Type

configuration (producer)

Component configuration.

ArangoDbConfiguration

documentCollection (producer)

Collection name, when using ArangoDb as a Document Database. Set the documentCollection name when using the CRUD operation on the document database collections (SAVE_DOCUMENT , FIND_DOCUMENT_BY_KEY, UPDATE_DOCUMENT, DELETE_DOCUMENT).

String

edgeCollection (producer)

Collection name of vertices, when using ArangoDb as a Graph Database. Set the edgeCollection name to perform CRUD operation on edges using these operations : SAVE_VERTEX, FIND_VERTEX_BY_KEY, UPDATE_VERTEX, DELETE_VERTEX. The graph attribute is mandatory.

String

graph (producer)

Graph name, when using ArangoDb as a Graph Database. Combine this attribute with one of the two attributes vertexCollection and edgeCollection.

String

host (producer)

ArangoDB host. If host and port are default, this field is Optional.

String

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

boolean

operation (producer)

Operations to perform on ArangoDb. For the operation AQL_QUERY, no need to specify a collection or graph.

Enum values:

  • SAVE_DOCUMENT

  • FIND_DOCUMENT_BY_KEY

  • UPDATE_DOCUMENT

  • DELETE_DOCUMENT

  • AQL_QUERY

  • SAVE_VERTEX

  • FIND_VERTEX_BY_KEY

  • UPDATE_VERTEX

  • DELETE_VERTEX

  • SAVE_EDGE

  • FIND_EDGE_BY_KEY

  • UPDATE_EDGE

  • DELETE_EDGE

ArangoDbOperation

port (producer)

ArangoDB exposed port. If host and port are default, this field is Optional.

int

vertexCollection (producer)

Collection name of vertices, when using ArangoDb as a Graph Database. Set the vertexCollection name to perform CRUD operation on vertices using these operations : SAVE_EDGE, FIND_EDGE_BY_KEY, UPDATE_EDGE, DELETE_EDGE. The graph attribute is mandatory.

String

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

password (security)

ArangoDB password. If user and password are default, this field is Optional.

String

user (security)

ArangoDB user. If user and password are default, this field is Optional.

String

Endpoint Options

The ArangoDb endpoint is configured using URI syntax:

arangodb:database

with the following path and query parameters:

Path Parameters (1 parameters)

Name Description Default Type

database (producer)

Required database name.

String

Query Parameters (10 parameters)

Name Description Default Type

documentCollection (producer)

Collection name, when using ArangoDb as a Document Database. Set the documentCollection name when using the CRUD operation on the document database collections (SAVE_DOCUMENT , FIND_DOCUMENT_BY_KEY, UPDATE_DOCUMENT, DELETE_DOCUMENT).

String

edgeCollection (producer)

Collection name of vertices, when using ArangoDb as a Graph Database. Set the edgeCollection name to perform CRUD operation on edges using these operations : SAVE_VERTEX, FIND_VERTEX_BY_KEY, UPDATE_VERTEX, DELETE_VERTEX. The graph attribute is mandatory.

String

graph (producer)

Graph name, when using ArangoDb as a Graph Database. Combine this attribute with one of the two attributes vertexCollection and edgeCollection.

String

host (producer)

ArangoDB host. If host and port are default, this field is Optional.

String

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

boolean

operation (producer)

Operations to perform on ArangoDb. For the operation AQL_QUERY, no need to specify a collection or graph.

Enum values:

  • SAVE_DOCUMENT

  • FIND_DOCUMENT_BY_KEY

  • UPDATE_DOCUMENT

  • DELETE_DOCUMENT

  • AQL_QUERY

  • SAVE_VERTEX

  • FIND_VERTEX_BY_KEY

  • UPDATE_VERTEX

  • DELETE_VERTEX

  • SAVE_EDGE

  • FIND_EDGE_BY_KEY

  • UPDATE_EDGE

  • DELETE_EDGE

ArangoDbOperation

port (producer)

ArangoDB exposed port. If host and port are default, this field is Optional.

int

vertexCollection (producer)

Collection name of vertices, when using ArangoDb as a Graph Database. Set the vertexCollection name to perform CRUD operation on vertices using these operations : SAVE_EDGE, FIND_EDGE_BY_KEY, UPDATE_EDGE, DELETE_EDGE. The graph attribute is mandatory.

String

password (security)

ArangoDB password. If user and password are default, this field is Optional.

String

user (security)

ArangoDB user. If user and password are default, this field is Optional.

String

Examples

Producer Examples

Save document on a collection

from("direct:insert")
  .to("arangodb:testDb?documentCollection=collection&operation=SAVE_DOCUMENT");

And you can set as body a BaseDocument class

        BaseDocument myObject = new BaseDocument();
        myObject.addAttribute("a", "Foo");
        myObject.addAttribute("b", 42);

Query a collection

from("direct:query")
  .to("arangodb:testDb?operation=AQL_QUERY

And you can invoke an AQL Query in this way

        String query = "FOR t IN " + COLLECTION_NAME + " FILTER t.value == @value";
        Map<String, Object> bindVars = new MapBuilder().put("value", "hello")
                .get();

        Exchange result = template.request("direct:query", exchange -> {
            exchange.getMessage().setHeader(AQL_QUERY, query);
            exchange.getMessage().setHeader(AQL_QUERY_BIND_PARAMETERS, bindVars);
        });

Spring Boot Auto-Configuration

When using arangodb with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:

<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-arangodb-starter</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

The component supports 13 options, which are listed below.

Name Description Default Type

camel.component.arangodb.autowired-enabled

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

Boolean

camel.component.arangodb.configuration

Component configuration. The option is a org.apache.camel.component.arangodb.ArangoDbConfiguration type.

ArangoDbConfiguration

camel.component.arangodb.document-collection

Collection name, when using ArangoDb as a Document Database. Set the documentCollection name when using the CRUD operation on the document database collections (SAVE_DOCUMENT , FIND_DOCUMENT_BY_KEY, UPDATE_DOCUMENT, DELETE_DOCUMENT).

String

camel.component.arangodb.edge-collection

Collection name of vertices, when using ArangoDb as a Graph Database. Set the edgeCollection name to perform CRUD operation on edges using these operations : SAVE_VERTEX, FIND_VERTEX_BY_KEY, UPDATE_VERTEX, DELETE_VERTEX. The graph attribute is mandatory.

String

camel.component.arangodb.enabled

Whether to enable auto configuration of the arangodb component. This is enabled by default.

Boolean

camel.component.arangodb.graph

Graph name, when using ArangoDb as a Graph Database. Combine this attribute with one of the two attributes vertexCollection and edgeCollection.

String

camel.component.arangodb.host

ArangoDB host. If host and port are default, this field is Optional.

String

camel.component.arangodb.lazy-start-producer

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

Boolean

camel.component.arangodb.operation

Operations to perform on ArangoDb. For the operation AQL_QUERY, no need to specify a collection or graph.

ArangoDbOperation

camel.component.arangodb.password

ArangoDB password. If user and password are default, this field is Optional.

String

camel.component.arangodb.port

ArangoDB exposed port. If host and port are default, this field is Optional.

Integer

camel.component.arangodb.user

ArangoDB user. If user and password are default, this field is Optional.

String

camel.component.arangodb.vertex-collection

Collection name of vertices, when using ArangoDb as a Graph Database. Set the vertexCollection name to perform CRUD operation on vertices using these operations : SAVE_EDGE, FIND_EDGE_BY_KEY, UPDATE_EDGE, DELETE_EDGE. The graph attribute is mandatory.

String