Chapter 154. Infinispan Component

This component allows you to interact with Infinispan distributed data grid / cache. Infinispan is an extremely scalable, highly available key/value data store and data grid platform written in Java.

From Camel 2.17 onwards Infinispan requires Java 8.

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

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

154.1. URI format

infinispan://cacheName?[options]

154.2. URI Options

The producer allows sending messages to a local infinispan cache configured in the registry, or to a remote cache using the HotRod protocol. The consumer allows listening for events from local infinispan cache accessible from the registry.

The Infinispan component supports 3 options which are listed below.

Name

Description

Default

Type

configuration (common)

The default configuration shared among endpoints.

InfinispanConfiguration

cacheContainer (common)

The default cache container.

BasicCacheContainer

resolveProperty Placeholders (advanced)

Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders.

true

boolean

The Infinispan endpoint is configured using URI syntax:

infinispan:cacheName

with the following path and query parameters:

154.2.1. Path Parameters (1 parameters):

Name

Description

Default

Type

cacheName

Required The cache to use

String

154.2.2. Query Parameters (18 parameters):

Name

Description

Default

Type

hosts (common)

Specifies the host of the cache on Infinispan instance

String

queryBuilder (common)

Specifies the query builder.

InfinispanQueryBuilder

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.

To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options 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

operation (producer)

The operation to perform.

PUT

InfinispanOperation

cacheContainer (advanced)

Specifies the cache Container to connect

BasicCacheContainer

cacheContainerConfiguration (advanced)

The CacheContainer configuration

Object

configurationProperties (advanced)

Implementation specific properties for the CacheManager

Map

configurationUri (advanced)

An implementation specific URI for the CacheManager

String

flags (advanced)

A comma separated list of Flag to be applied by default on each cache invocation, not applicable to remote caches.

String

resultHeader (advanced)

Store the operation result in a header instead of the message body. By default, resultHeader == null and the query result is stored in the message body, any existing content in the message body is discarded. If resultHeader is set, the value is used as the name of the header to store the query result and the original message body is preserved. This value can be overridden by an in message header named: CamelInfinispanOperationResultHeader

Object

synchronous (advanced)

Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported).

false

boolean

154.3. Message Headers

Name

Default Value

Type

Context

Description

CamelInfinispanCacheName

null

String

Shared

The cache participating in the operation or event.

CamelInfinispanOperation

PUT

InfinispanOperation

Producer

The operation to perform.

CamelInfinispanMap

null

Map

Producer

A Map to use in case of CamelInfinispanOperationPutAll operation

CamelInfinispanKey

null

Object

Shared

The key to perform the operation to or the key generating the event.

CamelInfinispanValue

null

Object

Producer

The value to use for the operation.

CamelInfinispanEventType

null

String

Consumer

The type of the received event. Possible values defined here org.infinispan.notifications.cachelistener.event.Event.Type

CamelInfinispanIsPre

null

Boolean

Consumer

Infinispan fires two events for each operation: one before and one after the operation.

CamelInfinispanLifespanTime

null

long

Producer

The Lifespan time of a value inside the cache. Negative values are interpreted as infinity.

CamelInfinispanTimeUnit

null

String

Producer

The Time Unit of an entry Lifespan Time.

CamelInfinispanMaxIdleTime

null

long

Producer

The maximum amount of time an entry is allowed to be idle for before it is considered as expired.

CamelInfinispanMaxIdleTimeUnit

null

String

Producer

The Time Unit of an entry Max Idle Time.

CamelInfinispanQueryBuilder

null

InfinispanQueryBuilder

Producer

From Camel 2.17: The QueryBuilde to use for QUERY command, if not present the command defaults to InifinispanConfiguration’s one

CamelInfinispanIgnoreReturnValues

null

Boolean

Producer

From Camel 2.17: If this header is set, the return value for cache operation returning something is ignored by the client application

CamelInfinispanOperationResultHeader

null

String

Producer

From Camel 2.20: Store the operation result in a header instead of the message body

154.4. Examples

Retrieve a specific key from the default cache using a custom cache container: