CarMart is a simple web application that uses Data Grid Cache instead of a relational database.
Users can list cars, add new cars, or remove them from the CarMart. Information about each car is stored in a cache. The application also shows cache statistics like stores, hits, retrievals, and more.
The CarMart quickstart can work in two modes:
-
Library mode - In this mode, the application and the data grid are running in the same JVM. All libraries (JAR files) are bundled with the application and deployed to Red Hat JBoss Enterprise Application Platform. The library mode enables fastest (local) access to the entries stored on the same node as the application instance, but also enables access to data stored in remote nodes (JVMs) that comprise the embedded distributed cluster.
-
Client-server mode - In this mode, the Cache is stored in a managed, distributed and clusterable data grid server. Applications can remotely access the data grid server using Hot Rod, memcached or REST client APIs. This web application bundles only the HotRod client and communicates with a remote Red Hat JBoss Data Grid (JDG) server.
All you need to build this project is Java SDK 1.8 or better, Maven 3.0 or better.
The application this project produces is designed to be run on Red Hat JBoss Enterprise Application Platform (EAP) 7.0 or later.
If you have not yet done so, you must Configure Maven before testing the quickstarts.
-
Open a command line and navigate to the root of the EAP server directory.
-
The following shows the command line to start the server with the web profile:
For Linux: $JBOSS_HOME/bin/standalone.sh For Windows: %JBOSS_HOME%\bin\standalone.bat
NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See the main README for more information.
-
Make sure you have started EAP as described above.
-
Open a command line and navigate to the root directory of this quickstart.
-
Type this command to build and deploy the archive:
mvn clean package wildfly:deploy -
This will deploy
target/jboss-carmart.warto the running instance of the server.
The application will be running at the following URL: http://localhost:8080/jboss-carmart/
-
Make sure you have started EAP as described above.
-
Open a command line and navigate to the root directory of this quickstart.
-
When you are finished testing, type this command to undeploy the archive:
mvn wildfly:undeploy
NOTE: The application must be deployed to Red Hat JBoss Enterprise Application Platform (EAP).
-
Obtain the DG server distribution. See the following for more information: http://www.redhat.com/products/jbossenterprisemiddleware/data-grid/. You can use this server configuration to make sure that the demo will work.
-
You will need an DG user for this demo. We are using the username "admin" and password "admin" as credentials for an admin user. If you want to use a different user, just change the configuration in RemoteCacheContainerProvider.java
-
Start the DG server on localhost:
$DG_HOME/bin/server.sh -
Create a cache with the following configuration:
Cache name: carcache
{
"distributed-cache": {
"mode": "SYNC",
"statistics": true,
"encoding": {
"key": {
"media-type": "application/x-java-serialized-object"
},
"value": {
"media-type": "application/x-java-serialized-object"
}
}
}
}
-
Start EAP into which you want to deploy your application
$EAP_HOME/bin/standalone.sh -
The application finds the DG server using the values in the RemoteCacheContainerProvider.java. If you are not running the DG server on the default host and port, you must modify this file to contain the correct values.
-
Build the application in the example's directory:
mvn clean package -Premote-eap -
Deploy the application
mvn wildfly:deploy -Premote-eap -
The application will be running at the following URL: http://localhost:8080/jboss-carmart/
-
Undeploy the application
mvn wildfly:undeploy -Premote-eap