第19章 The Cluster App Quickstart


19.1. EAP Cluster App Overview

The EAP Cluster App quickstart demonstrates how to use a JBoss Data Grid cache in library mode.

There are three different applications which show:

  • How to create and use a JBoss Data Grid clustered cache without having a JBoss EAP cluster.
  • A configuration where the JBoss EAP cluster is independent of an Infinispan cluster.
  • A JBoss EAP instance using a JBoss Data Grid cache that is a member of a different JBoss Data Grid cluster.
  • Programmatic cache configuration using the JBoss Data Grid API.
  • File based configuration, seen in administration application App1Cache.
  • CDI being used to inject the cache managers.

Overview of the EAP Cluster App Quickstart

Each application contains an embedded JBoss Data Grid cache which is accessed by stateless EJB’s in the same application. Different JBoss EAP servers, with the exception of AppTwo, are not clustered to demonstrate that an unclustered application can share the JBoss Data Grid cache; in addition, there are two cache managers, neither of which are members of the same JBoss Data Grid cluster. The AdminApp accesses and modified caches from both clusters. AppOne can only read the App1Cache, but it uses a clustered EJB invocation to AppTwo to read from App2Cache; AppTwo is deployed as a clustered EJB application and can only read App2Cache.

19.2. EAP Cluster App Prerequisites

The prerequisites for the EAP Cluster App are as follows:

  • Java 8.0 (Java SDK 1.8) or better
  • JBoss Enterprise Application Platform 7.0 or later
  • Maven 3.0 or better
  • Configure the Maven repository. For details, see Install and Use the Maven Repositories.
  • JBoss Data Grid modules installed in the JBoss EAP server.

19.3. Start the Application Server Instances

Configure and Start the Servers in standalone mode

  1. Prepare an instance of JBoss EAP for copying:

    1. Unzip jboss-datagrid-${version}-eap-modules-library.zip.
    2. Copy the modules to the server modules directory:

      • For Linux:

        cp -a jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME
        Copy to Clipboard Toggle word wrap

        For Windows:

         xcopy /e/i/f jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME\modules
        Copy to Clipboard Toggle word wrap
    3. Add a user to each server for EJB access:

      • For Linux: EAP_HOME/bin/add-user.sh -a -u quickuser -p quick-123
      • For Windows: EAP_HOME\bin\add-user.bat -a -u quickuser -p quick-123
  2. Copy the prepared JBoss EAP server to 4 different directories labeled EAP_HOME[1-4].
  3. Open a command line for each of the 4 nodes and navigate to the root of the JBoss EAP server directory.
  4. Start all four of the JBoss EAP servers using the following commands:

    • For Linux:

      EAP_HOME1/bin/standalone.sh -Djboss.node.name=node1
      EAP_HOME2/bin/standalone.sh -Djboss.node.name=node2 -Djboss.socket.binding.port-offset=100
      EAP_HOME3/bin/standalone.sh -Djboss.node.name=node3 -Djboss.socket.binding.port-offset=200 -c standalone-ha.xml
      EAP_HOME4/bin/standalone.sh -Djboss.node.name=node4 -Djboss.socket.binding.port-offset=300 -c standalone-ha.xml
      Copy to Clipboard Toggle word wrap
    • For Windows:

      EAP_HOME1\bin\standalone.bat -Djboss.node.name=node1
      EAP_HOME2\bin\standalone.bat -Djboss.node.name=node2 -Djboss.socket.binding.port-offset=100
      EAP_HOME3\bin\standalone.bat -Djboss.node.name=node3 -Djboss.socket.binding.port-offset=200 -c standalone-ha.xml
      EAP_HOME4\bin\standalone.bat -Djboss.node.name=node4 -Djboss.socket.binding.port-offset=300 -c standalone-ha.xml
      Copy to Clipboard Toggle word wrap
  5. Add the configuration for node2 (AppOne) to use EJB server-to-server invocation:

    • For Linux:

      EAP_HOME2/bin/jboss-cli.sh -c --controller=localhost:10099 --file=QUICKSTART_HOME/install-appOne-standalone.cli
      Copy to Clipboard Toggle word wrap

      For Windows:

      EAP_HOME2\bin\jboss-cli.bat -c --controller=localhost:10099 --file=QUICKSTART_HOME/install-appOne-standalone.cli
      Copy to Clipboard Toggle word wrap

Configure and Start the Servers in domain mode

  1. Copy a fresh JBoss EAP installation to EAP_HOME:

    1. Unzip jboss-datagrid-${version}-eap-modules-library.zip.
    2. Copy the modules to the server modules directory:

      • For Linux:

        cp -a jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME
        Copy to Clipboard Toggle word wrap
      • For Windows:

        xcopy /e/i/f jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME\modules
        Copy to Clipboard Toggle word wrap
  2. Open a command line and navigate to the root of JBoss EAP.
  3. Add a user:

    • For Linux:

      EAP_HOME/bin/add-user.sh -a -u quickuser -p quick-123
      Copy to Clipboard Toggle word wrap
    • For Windows:

      EAP_HOME\bin\add-user.bat -a -u quickuser -p quick-123
      Copy to Clipboard Toggle word wrap
  4. The following shows the command to start the domain:

    • For Linux:

      EAP_HOME/bin/domain.sh
      Copy to Clipboard Toggle word wrap
    • For Windows:

      EAP_HOME\bin\domain.bat
      Copy to Clipboard Toggle word wrap
  5. Apply the configuration for the quickstart, the domain will contain 4 nodes:

    • For Linux:

      EAP_HOME/bin/jboss-cli.sh -c --file=QUICKSTART_HOME/install-domain.cli
      Copy to Clipboard Toggle word wrap
    • For Windows:

      EAP_HOME\bin\jboss-cli.bat -c --file=QUICKSTART_HOME/install-domain.cli
      Copy to Clipboard Toggle word wrap

19.4. Build the Application

Build the Application

  1. Open a command line and navigate to the root directory of this quickstart.
  2. Execute the following command to build the archive:

    mvn clean install
    Copy to Clipboard Toggle word wrap
  3. Copy the application to the appropriate server:

    • For Linux:

      cp adminApp/ear/target/jboss-eap-application-adminApp.ear EAP_HOME1/standalone/deployments
      cp appOne/ear/target/jboss-eap-application-AppOne.ear EAP_HOME2/standalone/deployments
      cp appTwo/ear/target/jboss-eap-application-AppTwo.ear EAP_HOME3/standalone/deployments
      cp appTwo/ear/target/jboss-eap-application-AppTwo.ear EAP_HOME4/standalone/deployments
      Copy to Clipboard Toggle word wrap
    • For Windows:

      copy adminApp\ear\target\jboss-eap-application-adminApp.ear EAP_HOME1\standalone\deployments
      copy appOne\ear\target\jboss-eap-application-AppOne.ear EAP_HOME2\standalone\deployments
      copy appTwo\ear\target\jboss-eap-application-AppTwo.ear EAP_HOME3\standalone\deployments
      copy appTwo\ear\target\jboss-eap-application-AppTwo.ear EAP_HOME4\standalone\deployments
      Copy to Clipboard Toggle word wrap
  4. When domain mode is used, deploy the applications in the following way:

    • For Linux:

      EAP_HOME/bin/jboss-cli.sh -c --file=QUICKSTART_HOME/deploy-domain.cli
      Copy to Clipboard Toggle word wrap
    • For Windows:

      EAP_HOME\bin\jboss-cli.bat -c --file=QUICKSTART_HOME/deploy-domain.cli
      Copy to Clipboard Toggle word wrap

19.5. Run the Application

Once built the deployed applications may be accessed using the included classes.

Using the AdminClient

In this example neither the AdminServer nor the AppOneServer are clustered at the JBoss EAP level; only the JBoss Data Grid instances are clustered as configured by the application. This application will perform the following:

  • Add values to the App1 cache, using AdminApp, and validated they are replicated to the server instance of AppOne.
  • Add a value to the App2 cache, then rollback the transaction and confirm that it is not added to the cache after the rollback.

Procedure: Execute the AdminClient application

  1. Open a command line and navigate to the $QUICKSTART_HOME/client/ directory.
  2. Execute the following command:

    mvn -Dexec.mainClass=org.jboss.as.quickstarts.datagrid.eap.app.AdminClient exec:java
    Copy to Clipboard Toggle word wrap
    注記

    By default the application will attempt to access localhost:4447 and localhost:4547 for the AdminHost and AppOneHost. This may be changed by adding the following parameter to the mvn command:

    -Dexec.args="AdminHost AdminPort AppOneHost AppOnePort"
    Copy to Clipboard Toggle word wrap
  3. Confirm that the following text appears in the console; any unexpected results will raise an Exception:

    Add a value to App1Cache with the AdminApp and check on the same instance that the value is correct added
        success
    Check the previous added value of App1Cache by accessing the AppOne Server
        success
    Add a value to App2Cache and check on the same instance that the value is correct added
        success
    Check whether changes to a cache are rollbacked if the transaction fail
        The cache App2 work as expected on rollback
    Copy to Clipboard Toggle word wrap

Using the AppOneClient

In this example both JBoss EAP and the JBoss Data Grid caches are clustered; however, the purpose of this example is to demonstrate that the clusters are independent of one other. The JBoss Data Grid cluster is able to use a different JGroups implementation compared to the JBoss EAP servers, and this example will: ** Add values to the App2 cache using the AdminApp and access AppOne to show that the EJB invocation is clustered and both AppTwo instances are used.

Execute the AppOneClient

  1. Open a command line and navigate to the $QUICKSTART_HOME/client/ directory.
  2. Execute the following command:

    mvn -Dexec.mainClass=org.jboss.as.quickstarts.datagrid.eap.app.AppOneClient exec:java
    Copy to Clipboard Toggle word wrap
    注記

    By default the application will attempt to access localhost:4447 and localhost:4547 for the AdminHost and AppOneHost. This may be changed by adding the following parameter to the mvn command:

    -Dexec.args="AdminHost AdminPort AppOneHost AppOnePort"
    Copy to Clipboard Toggle word wrap
  3. Confirm that the following text appears in the console; any unexpected results will raise an Exception:

    Add a value to App2Cache with the AdminApp
    Access the App2Cache from the AppOneServer by using the clustered EJB@AppTwoServer
        success : received the following node names for EJB invocation : [node3, node4]
    Copy to Clipboard Toggle word wrap

19.6. Debug the Application

To debug, or examine the source code, of the quickstart or any of its associated libraries run either of the following commands to pull them into the local repository:

mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
Copy to Clipboard Toggle word wrap
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat