Olingo2 Component

Available as of Camel 2.14

The Olingo2 component utilizes Apache Olingo version 2.0 APIs to interact with OData 2.0 and 3.0 compliant services. A number of popular commercial and enterprise vendors and products support the OData protocol. A sample list of supporting products can be found on the OData website.

The Olingo2 component supports reading feeds, delta feeds, entities, simple and complex properties, links, counts, using custom and OData system query parameters. It supports updating entities, properties, and association links. It also supports submitting queries and change requests as a single OData batch operation. 

The component supports configuring HTTP connection parameters and headers for OData service connection. This allows configuring use of SSL, OAuth2.0, etc. as required by the target OData service. 

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


URI format



The Olingo2 Component can be configured with the options below. These options can be provided using the component's bean property configuration of type org.apache.camel.component.olingo2.Olingo2Configuration

serviceUriStringTarget OData service base URI, e.g. http://services.odata.org/OData/OData.svc
contentTypeStringContent-Type header value can be used to specify JSON or XML message format, defaults to application/json;charset=utf-8
connectTimeoutintHTTP connection creation timeout in milliseconds, defaults to 30,000 (30 seconds)
socketTimeoutintHTTP request timeout in milliseconds, defaults to 30,000 (30 seconds)
httpHeadersjava.util.Map<String, String>Custom HTTP headers to inject into every request, this could include OAuth tokens, etc.
proxyorg.apache.http.HttpHostHTTP proxy server configuration
sslContextjavax.net.ssl.SSLContextHTTP SSL configuration
httpAsyncClientBuilderorg.apache.http.impl.nio.client.HttpAsyncClientBuilderCustom HTTP async client builder for more complex HTTP client configuration, overrides connectionTimeout, socketTimeout, proxy and sslContext. Note that a socketTimeout MUST be specified in the builder, otherwise OData requests could block indefinitely

Producer Endpoints

Producer endpoints can use endpoint names and options listed next. Producer endpoints can also use a special option inBody that in turn should contain the name of the endpoint option whose value will be contained in the Camel Exchange In message. The inBody option defaults to data for endpoints that take that option. 

Any of the endpoint options can be provided in either the endpoint URI, or dynamically in a message header. The message header name must be of the format CamelOlingo2.<option>. Note that the inBody option overrides message header, i.e. the endpoint option inBody=option would override a CamelOlingo2.option header. In addition, query parameters can be specified 

Note that the resourcePath option can either in specified in the URI as a part of the URI path, as an endpoint option ?resourcePath=<resource-path> or as a header value CamelOlingo2.resourcePath. The OData entity key predicate can either be a part of the resource path, e.g. Manufacturers('1'), where '1' is the key predicate, or be specified separately with resource path Manufacturers and keyPredicate option '1'

EndpointOptionsHTTP MethodResult Body Type
POST with multipart/mixed batch request
createdata, resourcePath
org.apache.olingo.odata2.api.ep.entry.ODataEntry for new entries
org.apache.olingo.odata2.api.commons.HttpStatusCodes for other OData resources
mergedata, resourcePath
patchdata, resourcePath
readqueryParams, resourcePath
Depends on OData resource being queried as described next
updatedata, resourcePath

OData Resource Type Mapping

The result of read endpoint and data type of data option depends on the OData resource being queried, created or modified. 

OData Resource TypeResource URI from resourcePath and keyPredicateIn or Out Body Type
Entity data model$metadata
Service document/
OData feed<entity-set>
OData entry<entity-set>(<key-predicate>)
org.apache.olingo.odata2.api.ep.entry.ODataEntry for Out body (response)
java.util.Map<String, Object> for In body (request)
Simple property<entity-set>(<key-predicate>)/<simple-property>
Appropriate Java data type as described by Olingo EdmProperty
Simple property value<entity-set>(<key-predicate>)/<simple-property>/$value
Appropriate Java data type as described by Olingo EdmProperty
Complex property<entity-set>(<key-predicate>)/<complex-property>
java.util.Map<String, Object>
Zero or one association link<entity-set>(<key-predicate>/$link/<one-to-one-entity-set-property>
String for response
java.util.Map<String, Object> with key property names and values for request
Zero or many association links<entity-set>(<key-predicate>/$link/<one-to-many-entity-set-property>
java.util.List<String> for response
java.util.List<java.util.Map<String, Object>> containing list of key property names and values for request

URI Options

If a value is not provided for queryParams either in the endpoint URI or in a message header, it will be assumed to be null. Note that the null value will only be used if other options do not satisfy matching endpoints.

Data with appropriate type used to create or modify the OData resource
Key predicate to create a parameterized OData resource endpoint. Useful for create/update operations where the key predicate value is dynamically provided in a header
java.util.Map<String, String>
OData system options and custom query options. For more information see OData 2.0 URI Conventions
OData resource path, may or may not contain key predicate
Any other URI option is treated as a query parameter and added to query parameter map, overwriting entries in a queryParams option, if also specified

Consumer Endpoints

Only the read endpoint can be used as a consumer endpoint. Consumer endpoints can use Scheduled Poll Consumer Options with a consumer. prefix to schedule endpoint invocation. By default consumer endpoints that return an array or collection will generate one exchange per element, and their routes will be executed once for each exchange. This behavior can be disabled by setting the endpoint property consumer.splitResult=false

Message Headers

Any URI option can be provided in a message header for producer endpoints with a CamelOlingo2. prefix.

Message Body

All result message bodies utilize objects provided by the underlying Apache Olingo 2.0 API used by the Olingo2Component. Producer endpoints can specify the option name for incoming message body in the inBody endpoint URI parameter. For endpoints that return an array or collection, a consumer endpoint will map every element to distinct messages, unless consumer.splitResult is set to false.

Use cases

The following route reads top 5 entries from the Manufacturer feed ordered by ascending Name property. 


    .setHeader("CamelOlingo2.$top", "5");


The following route reads Manufacturer entry using the key property value in incoming id header. 


    .setHeader("CamelOlingo2.keyPredicate", header("id"))


The following route creates Manufacturer entry using the java.util.Map<String, Object> in body message. 




The following route polls Manufacturer delta feed every 30 seconds. The bean blah updates the bean paramsBean to add an updated !deltatoken property with the value returned in the ODataDeltaFeed result. Since the initial delta token is not known, the consumer endpoint will produce an ODataFeed value the first time, and ODataDeltaFeed on subsequent polls. 

  • No labels