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

5.1. 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.2. The camel-jbossdatagrid Component

The Red Hat JBoss Data Grid 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.

  • Remote Camel Consumer

    In Client-Server mode, receives cache change notifications and sends them to be processed. The events are processed asynchronously.

In JBoss Data Grid 7.2 the Camel component added the following features:

  • Aggregation Repository
  • Continuous Queries
  • Remote Cache Configuration (Hot Rod client configuration via properties)
  • Idempotent Repository
  • Cache Statistics
  • Store Results in Header
  • GetOrDefault Operation

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>7.2.0.Final-redhat-9</version>
</dependency>
Note

The camel-jbossdatagrid component ships with JBoss Data Grid, and is not included in JBoss Fuse 6.3.

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://cacheName?[options]

URI Options

The producer can create and send messages to a local or remote JBoss Data Grid cache configured in the registry. If a cacheContainer is present, the cache will be either local or remote, depending on whether the cacheContainer instance is a DefaultCacheManager or RemoteCacheManager. 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.

Table 5.1. URI Options

NameDetails

configuration

Default Value: null

Type: InfinispanConfiguration

Context: common

Description: The default configuration shared among endpoints.

cacheContainer

Default Value: null

Type: BasicCacheContainer

Context: common

Description: The default cache container.

resolveProperty Placeholders

Default Value: true

Type: boolean

Context: advanced

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

The JBoss Data Grid endpoint is configured with the following URI syntax:

infinispan://cacheName?[options]

This endpoint can take the following path and query parameters:

Table 5.2. Path Parameters

NameDetails

cacheName

Default Value: null

Type: string

Description: This is a required parameter that specifies the cache to use.

Table 5.3. Query Parameters

NameDetails

hosts

Default Value: null

Type: string

Context: common

Description: Specifies the host of the cache on the JBoss Data Grid instance.

queryBuilder

Default Value: null

Type: InfinispanQueryBuilder

Context: common

Description: Specifies the query builder.

bridgeErrorHandler

Default Value: false

Type: boolean

Context: consumer

Description: 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.

clusteredListener

Default Value: false

Type: boolean

Context: consumer

Description: If true the listener will be installed for the entire cluster.

customListener

Default Value: null

Type: InfinispanCustomListener

Context: consumer

Description: Returns the custom listener in use if provided

eventTypes

Default Value: null

Type: string

Context: consumer

Description: Specifies the set of event types to register by the consumer. Multiple event can be separated by comma. The possible event types are: CACHE_ENTRY_ACTIVATED CACHE_ENTRY_PASSIVATED CACHE_ENTRY_VISITED CACHE_ENTRY_LOADED CACHE_ENTRY_EVICTED CACHE_ENTRY_CREATED CACHE_ENTRY_REMOVED CACHE_ENTRY_MODIFIED TRANSACTION_COMPLETED TRANSACTION_REGISTERED CACHE_ENTRY_INVALIDATED DATA_REHASHED TOPOLOGY_CHANGED PARTITION_STATUS_CHANGED

sync

Default Value: true

Type: boolean

Context: consumer

Description: If true the consumer will receive notifications synchronously.

exceptionHandler

Default Value: null

Type: ExceptionHandler

Context: consumer

Description: 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.

exchangePattern

Default Value: null

Type: ExchangePattern

Context: consumer

Description: Sets the exchange pattern when the consumer creates an exchange.

operation

Default Value: PUT

Type: InfinispanOperation

Context: producer

Description: The operation to perform.

cacheContainer

Default Value: PUT

Type: BasicCacheContainer

Context: advanced

Description: Specifies the cache container to connect

cacheContainerConfiguration

Default Value: null

Type: object

Context: advanced

Description: The CacheContainer configuration

configurationProperties

Default Value: null

Type: map

Context: advanced

Description: Implementation specific properties for the CacheManager

configurationUri

Default Value: null

Type: string

Context: advanced

Description: An implementation specific URI for the CacheManager

flags

Default Value: null

Type: string

Context: advanced

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

resultHeader

Default Value: null

Type: object

Context: advanced

Description: 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

synchronous

Default Value: false

Type: boolean

Context: advanced

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

Camel Operations

A list of all available operations, along with their header information, is found below:

Table 5.4. Put Operations

Operation NameDescription

InfinispanOperation.PUT

Context: Embedded / Remote

Description: Puts a key/value pair in the cache, optionally with expiration

Required Headers: CamelInfinispanKey, CamelInfinispanValue

Optional Headers: CamelInfinispanLifespanTime, CamelInfinispanLifespanTimeUnit, CamelInfinispanMaxIdleTime, CamelInfinispanMaxIdleTimeUnit, CamelInfinispanIgnoreReturnValues

Result Header: CamelInfinispanOperationResult

InfinispanOperation.PUTASYNC

Description: Asynchronously puts a key/value pair in the cache, optionally with expiration

InfinispanOperation.PUTIFABSENT

Description: Puts a key/value pair in the cache if it did not exist, optionally with expiration

InfinispanOperation.PUTIFABSENTASYNC

Description: Asynchronously puts a key/value pair in the cache if it did not exist, optionally with expiration

Table 5.5. Put All Operations

Operation NameDescription

InfinispanOperation.PUTALL

Context: Embedded / Remote

Description: Adds multiple entries to a cache, optionally with expiration

Required Headers: CamelInfinispanMap

Optional Headers: CamelInfinispanLifespanTime, CamelInfinispanLifespanTimeUnit, CamelInfinispanMaxIdleTime, CamelInfinispanMaxIdleTimeUnit

Result Header: None

CamelInfinispanOperation.PUTALLASYNC

Description: Asynchronously adds multiple entries to a cache, optionally with expiration

Table 5.6. Get Operations

Operation NameDescription

InfinispanOperation.GET

Context: Embedded / Remote

Description: Retrieves the value associated with a specific key from the cache

Required Headers: CamelInfinispanKey

Optional Headers: None

Result Header: None

InfinispanOperation.GETORDEFAULT

Context: Embedded / Remote

Description: Retrieves the value, or default value, associated with a specific key from the cache

Required Headers: CamelInfinispanKey

Optional Headers: None

Result Header: None

Table 5.7. Contains Key Operation

Operation NameDescription

InfinispanOperation.CONTAINSKEY

Context: Embedded / Remote

Description: Determines whether a cache contains a specific key

Required Headers: CamelInfinispanKey

Optional Headers: None

Result Header: CamelInfinispanOperationResult

Table 5.8. Contains Value Operation

Operation NameDescription

InfinispanOperation.CONTAINSVALUE

Context: Embedded / Remote

Description: Determines whether a cache contains a specific value

Required Headers: CamelInfinispanKey

Optional Headers: None

Result Headers: None

Table 5.9. Remove Operations

Operation NameDescription

InfinispanOperation.REMOVE

Context: Embedded / Remote

Description: Removes an entry from a cache, optionally only if the value matches a given one

Required Headers: CamelInfinispanKey

Optional Headers: CamelInfinispanValue

Result Header: CamelInfinispanOperationResult

InfinispanOperation.REMOVEASYNC

Description: Asynchronously removes an entry from a cache, optionally only if the value matches a given one

Table 5.10. Replace Operations

Operation NameDescription

InfinispanOperation.REPLACE

Context: Embedded / Remote

Description: Conditionally replaces an entry in the cache, optionally with expiration

Required Headers: CamelInfinispanKey, CamelInfinispanValue, CamelInfinispanOldValue

Optional Headers: CamelInfinispanLifespanTime, CamelInfinispanLifespanTimeUnit, CamelInfinispanMaxIdleTime, CamelInfinispanMaxIdleTimeUnit, CamelInfinispanIgnoreReturnValues

Result Header: CamelInfinispanOperationResult

InfinispanOperation.REPLACEASYNC

Description: Asynchronously conditionally replaces an entry in the cache, optionally with expiration

Table 5.11. Clear Operations

Operation NameDescription

InfinispanOperation.CLEAR

Context: Embedded / Remote

Description: Clears the cache

Required Headers: None

Optional Headers: None

Result Header: None

InfinispanOperation.CLEARASYNC

Context: Embedded / Remote

Description: Asynchronously clears the cache

Required Headers: None

Optional Headers: None

Result Header: None

Table 5.12. Size Operation

Operation NameDescription

InfinispanOperation.SIZE

Context: Embedded / Remote

Description: Returns the number of entries in the cache

Required Headers: None

Optional Headers: None

Result Header: CamelInfinispanOperationResult

Table 5.13. Stats Operation

Operation NameDescription

InfinispanOperation.STATS

Context: Embedded / Remote

Description: Returns statistics about the cache

Required Headers: None

Optional Headers: None

Result Header: CamelInfinispanOperationResult

Table 5.14. Query Operation

Operation NameDescription

InfinispanOperation.QUERY

Context: Remote

Description: Executes a query on the cache

Required Headers: CamelInfinispanQueryBuilder

Optional Headers: None

Result Header: CamelInfinispanOperationResult

Note

Any operations that take CamelInfinispanIgnoreReturnValues will receive a null result.

Table 5.15. Message Headers

NameDescription

CamelInfinispanCacheName

Default Value: null

Type: String

Context: Shared

Description: The cache participating in the operation or event.

CamelInfinispanMap

Default Value: null

Type: Map

Context: Producer

Description: A Map to use in case of the CamelInfinispanOperationPutAll operation.

CamelInfinispanKey

Default Value: null

Type: Object

Context: Shared

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

CamelInfinispanValue

Default Value: null

Type: Object

Context: Producer

Description: The value to use for the operation.

CamelInfinispanOperationResult

Default Value: null

Type: Object

Context: Producer

Description: The result of the operation.

CamelInfinispanEventType

Default Value: null

Type: String

Context: Consumer

Description: For local cache listeners (non-clustered), one of the following values: CACHE_ENTRY_ACTIVATED, CACHE_ENTRY_PASSIVATED, CACHE_ENTRY_VISITED, CACHE_ENTRY_LOADED, CACHE_ENTRY_EVICTED, CACHE_ENTRY_CREATED, CACHE_ENTRY_REMOVED, CACHE_ENTRY_MODIFIED.

For remote HotRod listeners, one of the following values: CLIENT_CACHE_ENTRY_CREATED, CLIENT_CACHE_ENTRY_MODIFIED, CLIENT_CACHE_ENTRY_REMOVED, CLIENT_CACHE_FAILOVER.

CamelInfinispanIsPre

Default Value: null

Type: Boolean

Context: Consumer

Description: Infinispan fires two events for each operation when local non-clustered listener is used: one before and one after the operation. For clustered listeners and remote HotRod listeners, Infinispan fires only one event after the operation.

CamelInfinispanQueryBuilder

Default Value: null

Type: InfinispanQueryBuilder

Context: Producer

Description: An instance of InfinispanQueryBuilder that, in its build(), defines the query to be executed on the cache.

CamelInfinispanLifespanTime

Default Value: null

Type: long

Context: Producer

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

CamelInfinispanTimeUnit

Default Value: null

Type: String

Context: Producer

Description: The Time Unit of an entry Lifespan Time.

CamelInfinispanMaxIdleTime

Default Value: null

Type: long

Context: Producer

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

CamelInfinispanMaxIdleTimeUnit

Default Value: null

Type: String

Context: Producer

Description: The Time Unit of an entry Max Idle Time.

CamelInfinispanOperationResultHeader

Default Value: null

Type: String

Context: Producer

Description: Store the operation result in a header instead of the message body.

5.3. Routing with Camel in JBoss Data Grid

Camel routing is a chain of processors that move messages in the background. The following is an example of a route that retrieves a value from the cache for a specific key.

from("direct:start")
    .setHeader(InfinispanConstants.OPERATION).constant(InfinispanOperation.GET)
    .setHeader(InfinispanConstants.KEY).constant("123")
    .to("infinispan?cacheContainer=#cacheContainer");

Routing can also be performed using XML configuration. The following example demonstrates camel-jbossdatagrid’s local-camel-producer, a camel route that uses the camel-jbossdatagrid component to send data to an embedded cache created by the local-cache module.

<camelContext id="local-producer" xmlns="http://camel.apache.org/schema/blueprint">
    <route>
        <from uri="timer://local?fixedRate=true&amp;period=5000"/>
        <setHeader headerName="CamelInfinispanKey">
            <constant>CamelTimerCounter</constant>
        </setHeader>
        <setHeader headerName="CamelInfinispanValue">
            <constant>CamelTimerCounter</constant>
        </setHeader>
        <to uri="infinispan://foo?cacheContainer=#cacheManager"/>
        <to uri="log:local-put?showAll=true"/>
    </route>
</camelContext>

The provided example requires the cacheManager to be instantiated.

The cacheManager bean for Spring XML can be instantiated as follows:

<bean id="cacheManager" class="org.infinispan.manager.DefaultCacheManager" init-method="start" destroy-method="stop">
    <constructor-arg type="java.lang.String" value="infinispan.xml"/>
</bean>

The following demonstrates how to instantiate the cacheManager bean using Blueprint XML.

<bean id="cacheManager" class="org.infinispan.manager.DefaultCacheManager" init-method="start" destroy-method="stop">
    <argument value="infinispan.xml" />
</bean>
Note

Both the Spring XML and Blueprint XML examples use the configuration file infinispan.xml for configuration of the cache. This file must be present on the classpath.

5.4. Remote Query

When executing remote queries the cacheManager must be an instance of RemoteCacheManager, and an example configuration utilizing a RemoteCacheManager is found below for both Java and blueprint.xml:

Example 5.1. Using only Java

from("direct:start")
    .setHeader(InfinispanConstants.OPERATION, InfinispanConstants.QUERY)
    .setHeader(InfinispanConstants.QUERY_BUILDER,
      new InfinispanQueryBuilder() {
        public Query build(QueryFactory<Query> queryFactory) {
          return queryFactory.from(User.class).having("name").like("%abc%")
                      .build();
        }
      })
    .to("infinispan://localhost?cacheContainer=#cacheManager&cacheName=remote_query_cache") ;

Example 5.2. Using Blueprint and Java

Java RemoteCacheManagerFactory class:

public class RemoteCacheManagerFactory {
    ConfigurationBuilder clientBuilder;
    public RemoteCacheManagerFactory(String hostname, int port) {
        clientBuilder = new ConfigurationBuilder();
        clientBuilder.addServer()
            .host(hostname).port(port);
    }
    public RemoteCacheManager newRemoteCacheManager() {
        return new RemoteCacheManager(clientBuilder.build());
    }
}

Java InfinispanQueryExample class:

public class InfinispanQueryExample {
    public InfinispanQueryBuilder getBuilder() {
        return new InfinispanQueryBuilder() {
            public Query build(QueryFactory<Query> queryFactory) {
                return queryFactory.from(User.class)
                         .having("name")
                         .like("%abc%")
                         .build();
            }
        }
    }
}

blueprint.xml:

<bean id=”remoteCacheManagerFactory” class=“com.jboss.datagrid.RemoteCacheManagerFactory”>
    <argument value=”localhost”/>
    <argument value="11222”/>
</bean>

<bean id=”cacheManager”
    factory-ref=”remoteCacheManagerFactory”
    factory-method=“newRemoteCacheManager”>
</bean>

<bean id="queryBuilder" class="org.example.com.InfinispanQueryExample"/>

<camelContext id="route" xmlns="http://camel.apache.org/schema/blueprint">
    <route>
        <from uri="direct:start"/>
            <setHeader headerName="CamelInfinispanOperation">
                <constant>CamelInfinispanOperationQuery</constant>
            </setHeader>
            <setHeader headerName="CamelInfinispanQueryBuilder">
                <method ref="queryBuilder" method="getBuilder"/>
            </setHeader>
        <to uri="infinispan://localhost?cacheContainer=#cacheManager&cacheName=remote_query_cache"/>
    </route>
</camelContext>

The remote_query_cache is an arbitrary name for a cache that holds the data, and the results of the query will be a list of domain objects stored as a CamelInfinispanOperationResult header.

In addition, there are the following requirements:

  • The RemoteCacheManager must be configured to use ProtoStreamMarshaller.
  • The ProtoStreamMarshaller must be registered with the RemoteCacheManager's serialization context.
  • The .proto descriptors for domain objects must be registered with the remote JBoss Data Grid server.

For more details on how to setup a RemoteCacheManager, see the Remote Querying section of the Red Hat JBoss Data Grid Infinispan Query Guide .

5.5. Custom Listeners for Embedded Cache

Custom Listeners for an embedded cache can be registered through the customListener parameter as shown below:

Using Java

from("infinispan://?cacheContainer=#myCustomContainer&cacheName=customCacheName&customListener=#myCustomListener")
  .to("mock:result");

Using Blueprint

<bean id="myCustomContainer" org.infinispan.manager.DefaultCacheManager"
      init-method="start" destroy-method="stop">
      <argument value="infinispan.xml" />
</bean>

<bean id="myCustomListener" class="org.example.com.CustomListener"/>

<camelContext id="route" xmlns="http://camel.apache.org/schema/blueprint">
    <route>
        <from uri="infinispan://?cacheContainer=#myCustomContainer&cacheName=customCacheName&customListener=#myCustomListener"/>
        <to uri="mock:result"/>
    </route>
</camelContext>

The instance of myCustomListener must exist. Users are encouraged to extend the org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedCustomListener and annotate the resulting class with the @Listener annotation from org.infinispan.notifications .

Note

Custom filters and converters for embedded caches are currently not supported.

5.6. Custom Listeners for Remote Cache

Custom listeners for a remote cache can be registered in the same way as an embedded cache, with the exception that sync=false must be present. For instance:

Example 5.3. Using only Java

from(infinispan://?cacheContainer=#cacheManager&sync=false&customListener=#myCustomListener")
  .to(mock:result);

Example 5.4. Using Blueprint and Java

Java class:

public class RemoteCacheManagerFactory {
    ConfigurationBuilder clientBuilder;
    public RemoteCacheManagerFactory(String hostname, int port) {
        clientBuilder = new ConfigurationBuilder();
        clientBuilder.addServer()
            .host(hostname).port(port);
    }
    public RemoteCacheManager newRemoteCacheManager() {
        return new RemoteCacheManager(clientBuilder.build());
    }
}

blueprint.xml:

<bean id=”remoteCacheManagerFactory” class=“com.jboss.datagrid.RemoteCacheManagerFactory”>
    <argument value=”localhost”/>
    <argument value="11222”/>
</bean>

<bean id=”cacheManager”
    factory-ref=”remoteCacheManagerFactory”
    factory-method=“newRemoteCacheManager”>
</bean>

<bean id="myCustomListener" class="org.example.com.CustomListener"/>

<camelContext id="route" xmlns="http://camel.apache.org/schema/blueprint">
    <route>
        <from uri="infinispan://?cacheContainer=#cacheManager&sync=false&customListener=#myCustomListener"/>
        <to uri="mock:result"/>
    </route>
</camelContext>

The instance of myCustomListener must exist. Users are encouraged to extend the org.apache.camel.component.infinispan.remote.InfinispanRemoteCustomListener class and annotate the resulting class with @ClientListener; this annotation is found in org.infinispan.client.hotrod.annotation .

Remote listeners may also be associated with custom filters and converters as shown below:

@ClientListener(includeCurrentState=true, filterFactoryName = "static-filter-factory", converterFactoryName = "static-converter-factory")
  private static class MyCustomListener extends InfinispanRemoteCustomListener {
}

In order to use custom filters or converters classes annotated with @NamedFactory must be implemented. A skeleton that implements the necessary methods is shown below:

import org.infinispan.notifications.cachelistener.filter;

@NamedFactory(name = "static-converter-factory")
public static class StaticConverterFactory implements CacheEventConverterFactory {
  @Override
  public CacheEventConverter<Integer, String, CustomEvent> getConverter(Object[] params) {
    ...
  }

  static class StaticConverter implements CacheEventConverter<Integer, String, CustomEvent>, Serializable {
    @Override
    public CustomEvent convert(Integer key, String previousValue, Metadata previousMetadata,
                               String value, Metadata metadata, EventType eventType) {
      ...
    }
  }
}

@NamedFactory(name = "static-filter-factory")
public static class StaticCacheEventFilterFactory implements CacheEventFilterFactory {
  @Override
  public CacheEventFilter<Integer, String> getFilter(final Object[] params) {
    ...
  }

  static class StaticCacheEventFilter implements CacheEventFilter<Integer, String>, Serializable {
    @Override
    public boolean accept(Integer key, String previousValue, Metadata previousMetadata,
                          String value, Metadata metadata, EventType eventType) {
      ...
    }
  }
}

Custom filters and converters must be registered with the server. Registering these classes is documented in the Remote Event Listeners section of the Red Hat JBoss Data Grid Developer Guide .

Note

In order to listen for remote HotRod events the cacheManager must be of type RemoteCacheManager and instantiated.

5.7. Red Hat JBoss Data Grid and Red Hat JBoss Fuse

5.7.1. Installing camel-jbossdatagrid for Red Hat JBoss Fuse

Red Hat JBoss Fuse is an OSGi container based on the Karaf container. To run Red Hat JBoss Data Grid and JBoss Fuse using camel-jbossdatagrid, ensure that both JBoss Data Grid 7.2 and JBoss Fuse 6.1 (Full Installation) are installed.

Installing JBoss Data Grid

For information about installing JBoss Data Grid, see Download and Install Red Hat JBoss Data Grid . Only the following JBoss Data Grid components are required to run the camel component in JBoss Fuse: * JBoss Data Grid Maven repository. * The JBoss Data Grid Server package (to use the Hot Rod client).

The camel-jbossdatagrid library is also available in a separate distribution called jboss-datagrid-7.2.0-camel-library

Installing JBoss Fuse

Before attempting to install and use Red Hat JBoss Fuse, ensure your system meets the minimum requirements. For supported Platforms and recommended Java Runtime platforms, see the Red Hat JBoss Fuse Installation Guide

The following hardware is required for the JBoss Fuse 6.1 Full Installation:

  • 700 MB of free disk space
  • 2 GB of RAM

In addition to the disk space required for the base installation, a running system will require space for caching, persistent message stores, and other functions.

  1. Download the JBoss Fuse Full Installation

    You can download the Red Hat JBoss Fuse archive from the Red Hat Customer Portal>Downloads>Red Hat JBoss Middleware>Downloads page, after you register and login to your customer account.

    When logged in:

    1. Select Fuse , listed under Integrated Platforms in the sidebar menu.
    2. Select 6.1.0 from the Version drop-down list on the Software Downloads page.
    3. Click the Download button next to the Red Hat JBoss Fuse 6.1.0 distribution file to download.

    JBoss Fuse allows you to choose between installations that contain different feature sets. To run JBoss Data Grid with JBoss Fuse, the Full installation is required. The Full installation includes the following:

    • Apache Karaf
    • Apache Camel
    • Apache ActiveAMQ
    • Apache CXF
    • Fuse Management
    • Console (hawtio)
    • JBI components
  2. Unpacking the Archive

    Red Hat JBoss Fuse is installed by unpacking an archive on a system. JBoss Fuse is packaged as a zip file. Using a suitable archive tool, unpack Red Hat JBoss Fuse into a directory to which you have full access.

    Warning

    Do not unpack the archive file into a folder that has spaces in its path name. For example, do not unpack into C:\Documents and Settings\Greco Roman\Desktop\fusesrc.

    Additionally, do not unpack the archive file into a folder that has any of the following special characters in its path name: #, %, ^, ".

  3. Adding a Remote Console User

    The server’s remote command console is not configured with a default user. Before remotely connecting to the server’s console, add a user to the configuration.

    Important

    The information in this file is unencrypted so it is not suitable for environments that require strict security.

    To add a user:

    1. Open InstallDir/etc/users.properties in your favorite text editor.
    2. Locate the line #admin=admin,admin. This line specifies a user admin with the password admin and the role admin.
    3. Remove the leading # to uncomment the line.
    4. Replace the first admin with a name for the user.
    5. Replace the second admin with the password for the user.
    6. Leave the last admin as it is, and save the changes.
    Note

    To access the Fuse Management Console to monitor and manage your Camel routes, ActiveMQ brokers, Web applications, and so on, open a browser to , after starting Red Hat JBoss Fuse.

  4. Red Hat JBoss Fuse Maven Repositories

    To use Maven to build projects, specify the location of the artifacts in a Maven settings.xml file.

    The following JBoss Fuse Maven repository contains the required dependencies for Camel and must be added to the settings.xml file.

    https://repo.fusesource.com/nexus/content/groups/public/

    The JBoss Fuse repository runs alongside the JBoss Data Grid repository.

    JBoss Data Grid includes a features.xml file for Karaf that deploys all artifacts required for the camel-jbossdatagrid component. This file is not included in the JBoss Fuse container distribution. The features.xml file is in jboss-datagrid-7.2.0-maven-repository/org/apache/camel/camel-jbossdatagrid/${version}/ . No further configuration of the JBoss Data Grid repository is required.

    For more information about installing and getting started with JBoss Fuse, see the Red Hat JBoss Fuse documentation on the Red Hat Customer Portal.

5.8. Red Hat JBoss Data Grid and Red Hat JBoss EAP

5.8.1. Installing camel-jbossdatagrid for Red Hat JBoss Enterprise Application Platform

Red Hat JBoss Enterprise Application Platform 7 (JBoss EAP 7) is a middleware platform built on open standards and compliant with the Java Enterprise Edition 8 specification.

As Camel is only supported through Red Hat JBoss Fuse valid entitlements for all of the following products will be necessary:

  • Red Hat JBoss EAP
  • Red Hat JBoss Fuse
  • Red Hat JBoss Data Grid
Note

Entitlement to Red Hat JBoss Fuse Service Works includes entitlements to Red Hat JBoss EAP and Red Hat JBoss Fuse.

The following variables are used instead of specific version numbers in the installation procedures below:

  • jdg.version - the latest version of Red Hat JBoss Data Grid
  • fuse.version - the latest version of Red Hat JBoss Fuse
  • infinispan.version - the version of Infinispan that is included in the latest version of Red Hat JBoss Data Grid
  • camel.version - the version of Apache Camel that is included in the latest version of Red Hat JBoss Fuse

    For more information on tested integrations for ``camel-jbossdatagrid``, please refer to https://access.redhat.com/articles/115883.

Procedure: Installing JBoss Data Grid

For information about installing JBoss Data Grid, see Download and Install Red Hat JBoss Data Grid . Only the following JBoss Data Grid components are required to run the camel component in JBoss EAP: * JBoss Data Grid Maven repository. * The JBoss Data Grid Server package (to use the Hot Rod client).

The camel-jbossdatagrid library is also available in a separate distribution called jboss-datagrid-${jdg.version}-camel-library .

Installing JBoss EAP

  1. Before attempting to install and use Red Hat JBoss EAP ensure your system meets the minimum requirements as documented in Red Hat JBoss EAP Installation Guide.

  2. Unpacking the Archive

    Red Hat JBoss EAP is installed by unpacking an archive on a system, as JBoss EAP is packaged as a zip file; using a suitable archive tool, unpack Red Hat JBoss EAP into a directory to which you have full access.

    Warning

    Do not unpack the archive file into a folder that has spaces in its path name. For example, do not unpack into C:\Documents and Settings\Greco Roman\Desktop\JBoss.

    Additionally, do not unpack the archive file into a folder that has any of the following special characters in its path name: #, %, ^, ".

  3. Once the archive has been extracted JBoss EAP will have been successfully installed. For more information on installation options refer to the appropriate section, based on how JBoss EAP was installed, under Red Hat JBoss EAP Installation Guide.
  4. If JBoss Data Grid is being used in Library mode then refer to Deploy JBoss Data Grid in JBoss EAP (Library Mode) to ensure the necessary dependencies have been installed.
  5. If JBoss Data Grid is being used in Remote Client-Server mode then refer to Deploy JBoss Data Grid in JBoss EAP (Remote Client-Server Mode) to ensure the necessary dependencies have been installed.

5.8.2. Deploy Camel with EAP

5.8.2.1. Add development and runtime dependencies

In order to compile your application the dependent libraries for Camel and JBoss Data Grid will have to be added to the pom.xml (if using Maven).

Add Camel from Fuse

  1. Ensure that the Fuse repository has been added to the pom.xml:

    <repository>
      <id>fusesource</id>
      <name>FuseSource Release Repository</name>
      <url>https://repo.fusesource.com/nexus/content/groups/public/</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <enabled>true</enabled>
      </releases>
    </repository>
  2. Add the Camel components as a dependency in the pom.xml:

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
      <version>${camel.version}</version>
    </dependency>

Add camel-jbossdatagrid to the deployment.

  1. Follow the instructions in Install and Use the Maven Repositories to add the maven repository.
  2. Add camel-jbossdatagrid as a dependency in the pom.xml:

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-jbossdatagrid</artifactId>
      <version>${jdg.version}</version>
    </dependency>
  3. Add in the remaining JBoss Data Grid dependencies depending on which functionality is in use:

    <!-- If Remote Camel Producer is used add the following dependency -->
    <dependency>
    	<groupId>org.infinispan</groupId>
    	<artifactId>infinispan-remote</artifactId>
    	<version>${infinispan.version}</version>
    </dependency>
    
    <!-- If the Local Camel Producer or Local Camel Consumer are in use add -->
    <!-- the following dependency -->
    <dependency>
    	<groupId>org.infinispan</groupId>
    	<artifactId>infinispan-embedded</artifactId>
    	<version>${infinispan.version}</version>
    </dependency>

5.8.2.2. Optionally: Add runtime dependencies as a JBoss EAP Module

Sometimes it is preferable to maintain other product libraries in JBoss EAP as modules. This requires some additional procedures to create these modules.

Note

When using modules for dependencies the pom.xml will need to have the scope set to "provided" for any dependencies provided as modules. For example:

<dependency>
	<groupId>org.apache.camel</groupId>
	<artifactId>camel-jbossdatagrid</artifactId>
	<scope>provided</scope>
	<version>${jdg.version}</version>
</dependency>

Download jboss-datagrid-${jdg.version}-camel-library.zip from the customer portal.

Extract the apache-camel-${camel.version}.zip found in Red Hat JBoss Fuse’s extras/ directory:

user@example modules] unzip /path/to/jboss-fuse-${fuse.version}/extras/apache-camel-${camel.version}

Add in the Camel components from JBoss Fuse

  1. Create a directory under $EAP_HOME/modules:

    user@example jboss-eap-7.0] cd modules
    user@example modules] mkdir -p org/apache/camel/core
  2. Create a main subdirectory to store the jars:

    user@example modules] mkdir org/apache/camel/core/main
  3. Copy over the camel-core jar from apache-camel-${camel.version}.zip to the newly created main directory:

    user@example modules] cp /path/to/jboss/fuse/extras/apache-camel-${camel.version}/lib/camel-core-${camel.version}.jar ./org/apache/camel/core/main/
  4. Create the module.xml descriptor by adding in the following text to org/apache/camel/core/main/module.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.1" name="org.apache.camel.core">
      <resources>
        <resource-root path="camel-core-${camel.version}.jar"/>
      </resources>
    </module>
  5. Repeat the above steps to create a module for each dependency in use; note that modules may have dependencies on other modules as described in the Red Hat JBoss Administration and Configuration Guide .

Add in Camel components from JBoss Data Grid.

  1. Create a main subdirectory for the JDG Camel components:

    user@example jboss-eap-7.0] mkdir -p modules/org/apache/camel/main
  2. Unzip jboss-datagrid-${jdg.version}-camel-library.zip.
  3. Copy camel-jbossdatagrid-${jdg.version}.jar into the newly created directory:

    user@example jboss-eap-7.0] cp jboss-datagrid-${jdg.version}-camel-library/camel-jbossdatagrid-${jdg.version}.jar modules/org/apache/camel/main/
  4. Create a module.xml descriptor by adding in the following text to org/apache/camel/main/module.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.1" name="org.apache.camel">
      <resources>
        <resource-root path="camel-jbossdatagrid-${jdg.version}.jar"/>
      </resources>
      <dependencies>
        <module name="org.apache.camel.core" />
      </dependencies>
    </module>

Create a jboss-deployment-structure.xml in the WEB-INF of the war, and add dependencies on the newly created module:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.apache.camel" meta-inf="import"/>

            <!-- Add the following lines if Library mode is used -->
            <module name="org.infinispan" slot="jdg-7.2" />
            <module name="org.jgroups" slot="jdg-7.2" />

            <!-- Add the following lines if Remote Client-Server mode is used -->
            <module name="org.infinispan.client.hotrod" slot="jdg-7.2" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>