-
Language:
English
-
Language:
English
Chapter 15. The Hello World Quickstart
15.1. The Hello World Quickstart
Hello World is a simple quickstart that illustrates how to store and retrieve data from a cache using Red Hat JBoss Data Grid. For this quickstart, users can access the cache in two ways:
- from a servlet.
-
from a
JSF
page using request scoped beans.
All libraries (JAR files) bundles with the application are deployed to JBoss Enterprise Application Platform 7.x. JBoss Data Grid’s Library mode only allows local access to a single node in a distributed cluster. This mode also allows the application to access the data grid functionality within a virtual machine in the target container.
The Hello World quickstart works only in JBoss Data Grid’s Library mode.
Location
JBoss Data Grid’s Hello World quickstart is available at the following location: jboss-datagrid-{VERSION}-quickstarts/
15.2. Quickstart Prerequisites
The prerequisites for this quickstart are as follows:
- Java 8.0 (Java SDK 1.8) or better
- JBoss Enterprise Application Platform 7.x or JBoss Enterprise Web Server 2.x
- Maven 3.0 or better
- Configure the Maven Repository. For details, see Install and Use the Maven Repositories.
15.3. Start Two Application Server Instances
Before deploying the Hello World quickstart, start two instances of your application server (JBoss Enterprise Application Platform 7.x).
Start the First Application Server Instance
Navigate to the Root Directory
In the command line terminal, navigate to the root for your JBoss server directory.
Start the First Application Server
Depending on your operating system, use the appropriate command from the following to start the first instance of your selected application server:
For Linux:
$JBOSS_HOME/bin/standalone.sh
For Windows:
$JBOSS_HOME\bin\standalone.bat
Start the Second Application Server Instance
Clone the Application Server
Create a copy of the selected JBoss Server to create a second instance.
Navigate to the Root Directory
In the command line terminal, navigate to the root for your JBoss server directory.
Start the Second Application Server
Use the appropriate command for your operating system from the following commands. This command starts the server with the provided port offset to ensure that both the server instances run on the same host.
For Linux:
$JBOSS_HOME2/bin/standalone.sh -Djboss.socket.binding.port-offset=100
For Windows:
$JBOSS_HOME2\bin\standalone.bat -Djboss.socket.binding.port-offset=100
15.4. Build and Deploy the Hello World Quickstart
Before building and deploying the quickstart, ensure that all the listed prerequisites are met and that the two application server instances are running (see for details).
Build and Deploy the Hello World Quickstart
Navigate to the Required Directory
In the command line terminal, navigate to the root directory of the quickstart on the command line interface.
Build and Deploy to the First Application Server Instance
Use the following command to build and deploy the quickstart to the first application server instance as follows:
# mvn clean package wildfly:deploy
This command deploys target/[path]jboss-helloworld-jdg.war to the first running server instance.
Build and Deploy the Second Application Server Instance
Use the following command to build and deploy the quickstart to the second application server instance with the specified ports as follows:
# mvn clean package wildfly:deploy -Dwildfly.port=10090
This command deploys target/[path]jboss-helloworld-jdg.war to the second running server instance.
15.5. Access the Running Application
The Hello World quickstart application runs on the following URLs:
- First Server Instance: http://localhost:8080/jboss-helloworld-jdg
- Second Server Instance: http://localhost:8180/jboss-helloworld-jdg
15.6. Test Replication on the Application
Use the following instructions to test that cache entries are replicating from the first server instance to the second as desired.
Test Replication on the Application
Access the First Server
Access the first application server and enter the key and value.
Access the first application server in a browser window using the following URL:
http://localhost:8080/jboss-helloworld-jdg
-
Insert the key
foo
. -
Insert the value
bar
.
Access the Second Server
Access the second application server and enter the key and value.
Access the second application server in a browser window using the following URL:
http://localhost:8180/jboss-helloworld-jdg
- Click Get Some.
-
Get the key
foo
. - Click Put Some More.
-
Insert the key
mykey
. -
Insert the value
myvalue
.
Get All Keys and Values
Access the first server and request all keys.
Access the first application server in a browser window using the following URL:
http://localhost:8080/jboss-helloworld-jdg
- Click Get Some.
- Click Get All to request all key and values.
As the results of the last step show, all the data added at each server has been replicated to the other server.
Entries expire after 60
seconds from the most recent update.
Directly Access Keys in the Cache
To interact with predefined servlets or to directly store and retrieve keys from the cache, use the following URLs:
http://localhost:8080/jboss-helloworld-jdg/TestServletPut
http://localhost:8180/jboss-helloworld-jdg/TestServletGet
15.7. Remove the Application
Use the following procedure to remove the Hello World application:
Remove the Application
Start the Application Servers
Ensure that both server instances are running.
Navigate to the Root
In the command line terminal, navigate to the root directory of the quickstart.
Remove the Archive
Use the following commands to remove the archive from both the server instances.
Remove the archive from the first server as follows:
mvn wildfly:undeploy
Remove the archive from the second server as follows:
mvn wildfly:undeploy -Dwildfly.port=10090