Chapter 36. Integration with EAP
36.1. Integration with EAP
While EAP includes Infinispan modules, they are intended for internal EAP use, and are not supported with JBoss Data Grid. To use JDG within EAP, use the JDG provided EAP modules. Using these modules will avoid any conflict with EAP’s internal modules because the slot will be different. Using them will also allow for deployment of an application without packaging JDG within the deployments (WARs, EARs, etc.), thus minimizing their size.
36.2. Installation of EAP Modules
The modules for EAP can be downloaded from the Red Hat Customer Portal:
Procedure: Download EAP Modules
- Log into the Customer Portal at https://access.redhat.com.
- Click the Downloads button near the top of the page.
- In the Product Downloads page, click Red Hat JBoss Data Grid.
- Select the appropriate JBoss Data Grid version from the Version: drop down menu.
- Locate the Red Hat JBoss Data Grid 7.2 Library Module for JBoss EAP entry and click the corresponding Download link.
The zip file should be extracted to EAP_HOME/modules
. If the files were extracted correctly the infinispan core module would be under EAP_HOME/modules/org/infinispan/core
.
36.3. EAP Dependencies
To configure the modules using Maven, mark the JDG dependencies as provided and configure the artifact archiver to generate a WAR file with the proper MANIFEST.MF
using the following pom.xml
:
pom.xml
<dependencies> <dependency> <groupId>org.infinispan</groupId> <artifactId>infinispan-core</artifactId> <version>${infinispan.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.infinispan</groupId> <artifactId>infinispan-cachestore-jdbc</artifactId> <version>${infinispan.version}</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <archive> <manifestEntries> <Dependencies>org.infinispan.core:jdg-7.2 services, org.infinispan.cachestore.jdbc:jdg-7.2 services</Dependencies> </manifestEntries> </archive> </configuration> </plugin> </plugins> </build>
36.4. Dependencies for Specific JDG Components
Various example MANIFEST.MF
configuration files to enable specific features of JDG are provided below.
36.4.1. Core Dependencies
To expose only JDG core dependencies to an application, add the following to the manifest:
MANIFEST.MF
Manifest-Version: 1.0 Dependencies: org.infinispan:jdg-7.2 services
36.4.2. Remote/Hot Rod Dependencies
To connect to remote JDG servers via Hot Rod, including for execution of remote queries, use the module
. This exposes all needed dependencies automatically:
org.infinispan.remote
MANIFEST.MF
Manifest-Version: 1.0 Dependencies: org.infinispan.remote:jdg-7.2 services
36.4.3. Embedded Querying Dependencies
For embedded querying, including the Infinispan Query DSL, Lucene, and Hibernate Search Queries, add the following to the manifest:
MANIFEST.MF
Manifest-Version: 1.0 Dependencies: org.infinispan:jdg-7.2 services, org.infinispan.query:jdg-7.2 services
36.4.4. Lucene Directory Dependencies
To use JDG as a directory for Lucene using org.apache.lucene.store.Directory, the query module isn’t needed, the following is sufficient
MANIFEST.MF
Manifest-Version: 1.0 Dependencies: org.infinispan.lucene-directory:jdg-7.2 services
36.4.5. Hibernate Search Directory Provider Dependencies
The Hibernate Search directory provider for JDG is also contained within the JBoss Data Grid 7.2 Library Module for JBoss EAP zip file. It is not necessary to add an entry to the manifest file since the Hibernate Search module already has an optional dependency to it. When deciding what JDG module zip to use, start by checking which Hibernate Search is in use.
36.4.6. Using EAP’s Internal Hibernate Search Modules
The Hibernate Search module present in EAP 7.1 has version 5.5.x, and has an optional dependency to module org.infinispan.hibernate-search.directory-provider
, with slot for-hibernatesearch-5.5
. This dependency is available once the Infinispan modules are installed.
36.4.7. Usage with Other Hibernate Search Modules
The module org.hibernate.search:jdg-7.2
distributed with JDG is to be used together with Infinispan Query only (querying data from caches), and should not be used by Hibernate ORM applications. To use a Hibernate Search with a different version that is present in EAP, consult the Hibernate Search documentation.
Make sure the chosen Hibernate Search optional slot for org.infinispan.hibernate-search.directory-provider
matches the one distributed with JBoss Data Grid.
36.5. Usage of EAP Modules
An application can use JDG within EAP either in Library (embedded) Mode, or in EAP Subsystem Mode.
36.5.1. Library Mode
When using JDG within EAP in Library Mode, all CacheManager
and cache instances are created in application logic. As such, the lifecycle of the EmbeddedCacheManager
is tightly coupled with the application’s lifecycle, resulting in any manager instances created by the application being destroyed when the application is destroyed.
36.5.2. EAP Subsystem Mode
In EAP Subsystem Mode, where JDG is a subsystem to EAP, it’s possible for cache containers and caches to be created before runtime as part of EAP’s domain/configuration/domain.xml
configuration. This allows cache instances to be shared across multiple applications, with the lifecycle of the underlying cache container being independent of the deployed application.
36.6. Configuration for EAP Subsystem Mode
To enable EAP Subsystem Mode, add the following to the EAP configuration in domain/configuration/domain.xml
.
Only the first two steps are required for local cache instances.
-
Add the infinispan extensions to the
<extensions>
section
<extensions> <extension module="org.infinispan.extension:jdg-7.2"/> <extension module="org.jgroups.extension:jdg-7.2"/> <!--Other EAP extensions--> </extensions>
- Configure the Infinispan subsystem, along with all required containers and caches, in the server profile which requires Infinispan.
Ensure the module attribute is defined or else the correct Infinispan classes won’t be loaded.
<subsystem xmlns="urn:infinispan:server:core:8.5"> <cache-container name="jdg-container" default-cache="default" module="org.infinispan.extension:jdg-7.2"> <transport channel="jdg-cluster"/> <global-state/> <distributed-cache-configuration name="default"/> <distributed-cache name="default"/> </cache-container> </subsystem>
- Define the EAP interface and socket bindings required by JGroup subsystems.
Interface definition:
<interfaces> <interface name="jdg"> <inet-address value="${jdg.bind.address:127.0.0.1}"/> </interface> </interfaces>
Socket bindings definition:
<socket-binding-group name="full-sockets" default-interface="public"> <socket-binding name="jdg-jgroups-udp" interface="jdg" port="55200" multicast-address="${jdg.default.multicast.address:230.0.0.4}" multicast-port="45688"/> <socket-binding name="jdg-jgroups-udp-fd" interface="jdg" port="54200"/> </socket-binding-group>
For more information on EAP interface and socket bindings see Network and Port Configuration in the EAP Configuration Guide.
- Define JGroups transport, ensuring the model attribute, for all protocols specified, is defined.
<subsystem xmlns="urn:infinispan:server:jgroups:8.0"> <channels> <channel name="jdg-cluster" stack="udp"/> </channels> <stacks> <stack name="udp"> <transport type="UDP" socket-binding="jdg-jgroups-udp" module="org.jgroups:jdg-7.2"/> <protocol type="PING" module="org.jgroups:jdg-7.2"/> <protocol type="MERGE3" module="org.jgroups:jdg-7.2"/> <protocol type="FD_SOCK" socket-binding="jdg-jgroups-udp-fd" module="org.jgroups:jdg-7.2"/> <protocol type="FD_ALL" module="org.jgroups:jdg-7.2"/> <protocol type="VERIFY_SUSPECT" module="org.jgroups:jdg-7.2"/> <protocol type="pbcast.NAKACK2" module="org.jgroups:jdg-7.2"/> <protocol type="UNICAST3" module="org.jgroups:jdg-7.2"/> <protocol type="pbcast.STABLE" module="org.jgroups:jdg-7.2"/> <protocol type="pbcast.GMS" module="org.jgroups:jdg-7.2"/> <protocol type="UFC" module="org.jgroups:jdg-7.2"/> <protocol type="MFC" module="org.jgroups:jdg-7.2"/> <protocol type="FRAG3" module="org.jgroups:jdg-7.2"/> </stack> </stacks> </subsystem>
A command line script is also available to configure server mode:
# adding the necessary modules to the EAP configuration # remember to add the datagrid library modules of JDG 7.2 before ! /extension=org.infinispan.extension\:jdg-7.2:add /extension=org.jgroups.extension\:jdg-7.2:add batch /profile=full/subsystem=datagrid-infinispan:add /profile=full/subsystem=datagrid-infinispan/cache-container=jdg-container:add(module="org.infinispan.extension:jdg-7.2", default-cache="default" /profile=full/subsystem=datagrid-infinispan/cache-container=jdg-container/transport=TRANSPORT:add(channel=jdg-cluster) /profile=full/subsystem=datagrid-infinispan/cache-container=jdg-container/global-state=GLOBAL_STATE:add # add an interface for JDG cluster communication, can be skipped if the same as JGroups or public is used /interface=jdg:add(inet-address="${jdg.bind.address:127.0.0.1}" # add the port numbers for JDG JGroups /socket-binding-group=full-sockets/socket-binding=jdg-jgroups-udp:add(interface="jdg", port=55200, multicast-address="${jdg.default.multicast.address:230.0.0.4}", multicast-port="45688" /socket-binding-group=full-sockets/socket-binding=jdg-jgroups-udp-fd:add(port=54200, interface="jdg") # adding the datagrid JGroups subsystem with UDP stack /profile=full/subsystem=datagrid-jgroups:add(default-channel=jdg-cluster) /profile=full/subsystem=datagrid-jgroups/channel=jdg-cluster:add(stack=udp) /profile=full/subsystem=datagrid-jgroups/stack=udp:add() /profile=full/subsystem=datagrid-jgroups/stack=udp/transport=UDP:add(socket-binding=jdg-jgroups-udp, module="org.jgroups:jdg-7.2") /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=PING:add(module="org.jgroups:jdg-7.2") /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=MERGE3:add(module="org.jgroups:jdg-7.2") /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=FD_SOCK:add(module="org.jgroups:jdg-7.2", socket-binding=jdg-jgroups-udp-fd) /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=FD_ALL:add(module="org.jgroups:jdg-7.2") /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=VERIFY_SUSPECT:add(module="org.jgroups:jdg-7.2") /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=pbcast.NAKACK2:add(module="org.jgroups:jdg-7.2") /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=UNICAST3:add(module="org.jgroups:jdg-7.2") /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=pbcast.STABLE:add(module="org.jgroups:jdg-7.2") /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=pbcast.GMS:add(module="org.jgroups:jdg-7.2") /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=UFC:add(module="org.jgroups:jdg-7.2") /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=MFC:add(module="org.jgroups:jdg-7.2") /profile=full/subsystem=datagrid-jgroups/stack=udp/protocol=FRAG3:add(module="org.jgroups:jdg-7.2") # add a configuration as this is needed if the CLI is used to add a cache /profile=full/subsystem=datagrid-infinispan/cache-container=jdg-container/configurations=CONFIGURATIONS:add /profile=full/subsystem=datagrid-infinispan/cache-container=jdg-container/configurations=CONFIGURATIONS/distributed-cache-configuration=default:add run-batch
To add the cache use the following command:
# add a simple cache /profile=full/subsystem=datagrid-infinispan/cache-container=jdg-container/distributed-cache=default:add(configuration=default)
36.7. Accessing Containers and Caches Remotely
Once a container has been defined in the server’s configuration, it is possible to inject an instance of a CacheContainer
or Cache
into the application using the @Resource
JNDI lookup. A container is accessed using the string java:jboss/datagrid-infinispan/container/<container_name>
, and similarly, a cache is accessed via java:jboss/datagrid-infinispan/container/<container_name>/cache/<cache_name>
.
The example below shows how to inject the CacheContainer
called "jdg-container" and the distributed cache "default" into an application.
public class ExampleApplication { @Resource(lookup = "java:jboss/datagrid-infinispan/container/jdg-container") CacheContainer container; @Resource(lookup = "java:jboss/datagrid-infinispan/container/jdg-container/cache/default") Cache cache; }
This example code has a dependency on the jdg-7.2
module.
36.8. Troubleshooting EAP and JDG in EAP Subsystem Mode
36.8.1. Enable logging
Enabling trace on org.jboss.modules
can be useful to debug issues like LinkageError
and ClassNotFoundException
. To enable trace logging at runtime use the EAP CLI:
bin/jboss-cli.sh -c '/subsystem=logging/logger=org.jboss.modules:add' bin/jboss-cli.sh -c '/subsystem=logging/logger=org.jboss.modules:write-attribute(name=level,value=TRACE)'
36.8.2. Print Dependency Tree
The following command can be used to print all dependencies for a certain module. For example, to obtain the tree for the module org.infinispan:jdg-7.2
, execute the following from EAP_HOME
:
java -jar jboss-modules.jar -deptree -mp modules/ "org.infinispan:jdg-7.2"