Chapter 5. Running Red Hat JBoss Data Grid with Apache Camel


Apache Camel is an open source integration and routing system that allows transference of messages from various sources to different destinations, providing an integration framework that allows interaction with various systems using the same API, regardless of the protocol or data type. Using Camel with Red Hat JBoss Data Grid and Red Hat JBoss Fuse simplifies integration in large enterprise applications by providing a wide variety of transports and APIs that add connectivity.
JBoss Data Grid provides support for caching on Camel routes in JBoss Fuse, partially replacing Ehcache. JBoss Data Grid is supported as an embedded cache (local or clustered) or as a remote cache in a Camel route.

5.1. The camel-jbossdatagrid Component

Red Hat JBoss Data Grid's camel-jbossdatagrid component includes the following features:
  • Local Camel Consumer

    Receives cache change notifications and sends them to be processed. This can be done synchronously or asynchronously, and is also supported with a replicated or distributed cache.

  • Local Camel Producer

    A producer creates and sends messages to an endpoint. The camel-jbossdatagrid producer uses GET, PUT, REMOVE, and CLEAR operations. The local producer is also supported with a replicated or distributed cache.

  • Remote Camel Producer

    In Remote Client-Server mode, the Camel producer can send messages using Hot Rod.

The following camel-jbossdatagrid dependency must be added to the pom.xml file to run JBoss Data Grid with Camel:
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-jbossdatagrid</artifactId>
    <version>6.4.0.Final-redhat-3</version>
    <!-- use the same version as your JBoss Data Grid version -->
</dependency>
Copy to Clipboard Toggle word wrap

Note

The camel-jbossdatagrid component ships with JBoss Data Grid, and is not included in the JBoss Fuse 6.1 or JBoss Fuse Service Works 6.0 distributions.
Camel components are the main extension point in Camel, and are associated with the name used in a URI, and act as a factory of endpoints. For example, a FileComponent is referred to in a URI as file, which creates FileEndpoints.
URI Format

The following URI format is used for camel-jbossdatagrid:

infinispan://hostname?[options]
Copy to Clipboard Toggle word wrap
URI Options

The producer can create and send messages to a local JBoss Data Grid cache configured in the registry, or to a remote cache using the Hot Rod protocol. If a cacheContainer is present, the cache will be local. If it is not present, the cache will try to connect to remote cache using the supplied hostname/port.

A consumer listens for events from the local JBoss Data Grid cache accessible from the registry.
Expand
Table 5.1. URI Options
Name Default Value Type Context Description
cacheContainer null CacheContainer Shared Reference to a org.infinispan.manager.CacheContainer in the Registry.
cacheName null String Shared The cache name to use. If not specified, the default cache is used.
command PUT String Producer The operation to perform. Only the PUT, GET, REMOVE, and CLEAR values are currently supported.
eventTypes null Set<String> Consumer The event types to register. By default, this listens for all event types. Possible values are defined in org.infinispan.notifications.cachelistener.event.Event.Type
sync true Boolean Consumer By default the consumer will receive notifications synchronously by the same thread that process the cache operation.
clustered false Boolean Consumer By default the consumer will only receive local events. By using this option, the consumer also listens to events originated on other nodes in the cluster. The only events available for clustered listeners are CACHE_ENTRY_CREATED, CACHE_ENTRY_REMOVED, and CACHE_ENTRY_MODIFIED.
Expand
Table 5.2. Message Headers
Name Default Value Type Context Description
CamelInfinispanCacheName null String Shared The cache participating in the operation or event.
CamelInfinispanOperation PUT String Producer The operation to perform: CamelInfinispanOperationPut, CamelInfinispanOperationGet, CamelInfinispanOperationRemove, CamelInfinispanOperationClear.
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.
CamelInfinispanOperationResult null Object Producer The result of the operation.
CamelInfinispanEventType null String Consumer The type of the received event. Possible values are defined in 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.
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat