The helloworld-jms quickstart demonstrates the use of external JMS clients with JBoss EAP.
What is it?
The helloworld-jms quickstart demonstrates the use of external JMS clients with JBoss Enterprise Application Platform Server.
It contains the following:
-
A message producer that sends messages to a JMS destination deployed to a JBoss EAP server.
-
A message consumer that receives message from a JMS destination deployed to a JBoss EAP server.
System Requirements
The application this project produces is designed to be run on JBoss Enterprise Application Platform Server 7.2 or later.
All you need to build this project is Java 8.0 (Java SDK 1.8) or later and Maven 3.3.1 or later. See Configure Maven to Build and Deploy the Quickstarts to make sure you are configured correctly for testing the quickstarts.
To run these quickstarts with the provided build scripts, you need the JBoss EAP distribution ZIP. For information on how to install and run the JBoss EAP server, see the Getting Started Guide.
Use of EAP_HOME
In the following instructions, replace EAP_HOME with the actual path to your JBoss EAP installation. The installation path is described in detail here: Use of EAP_HOME and JBOSS_HOME Variables.
Add the Authorized Application User
This quickstart uses secured management interfaces and requires that you create the following application user to access the running application.
| UserName | Realm | Password | Roles |
|---|---|---|---|
quickstartUser |
ApplicationRealm |
quickstartPwd1! |
guest |
To add the application user, open a terminal and type the following command:
$ EAP_HOME/bin/add-user.sh -a -u 'quickstartUser' -p 'quickstartPwd1!' -g 'guest'
|
Note
|
For Windows, use the EAP_HOME\bin\add-user.bat script.
|
If you prefer, you can use the add-user utility interactively.
For an example of how to use the add-user utility, see the instructions located here: Add an Application User.
Back Up the JBoss EAP Standalone Server Configuration
Before you begin, back up your server configuration file.
-
If it is running, stop the JBoss EAP server.
-
Back up the
EAP_HOME/standalone/configuration/standalone-full.xmlfile.
After you have completed testing this quickstart, you can replace this file to restore the server to its original configuration.
Start the JBoss EAP Standalone Server
-
Open a terminal and navigate to the root of the JBoss EAP directory.
-
Start the JBoss EAP server with the full profile by typing the following command.
$ EAP_HOME/bin/standalone.sh -c standalone-full.xmlNoteFor Windows, use the EAP_HOME\bin\standalone.batscript.
Configure the Server
You configure the JMS test queue by running JBoss CLI commands. For your convenience, this quickstart batches the commands into a configure-jms.cli script provided in the root directory of this quickstart.
-
Before you begin, make sure you do the following:
-
Back up the JBoss EAP standalone server configuration as described above.
-
Start the JBoss EAP server with the standalone full profile as described above.
-
-
Review the
configure-jms.clifile in the root of this quickstart directory. This script adds thetestqueue to themessagingsubsystem in the server configuration file. -
Open a new terminal, navigate to the root directory of this quickstart, and run the following command, replacing EAP_HOME with the path to your server:
$ EAP_HOME/bin/jboss-cli.sh --connect --file=configure-jms.cliNoteFor Windows, use the EAP_HOME\bin\jboss-cli.batscript. -
You should see the following result when you run the script:
The batch executed successfully -
Stop the JBoss EAP server.
Review the Modified Server Configuration
After stopping the server, open the EAP_HOME/standalone/configuration/standalone-full.xml file and review the changes.
The following testQueue jms-queue was configured in the default server configuration of the messaging-activemq subsystem.
<jms-queue name="testQueue" entries="queue/test java:jboss/exported/jms/queue/test"/>
Build and Execute the Quickstart
-
Start the JBoss EAP server with the standalone full profile as described above.
-
Open a terminal and navigate to the root of the helloworld-jms quickstart directory:
$ cd PATH_TO_QUICKSTARTS/helloworld-jms -
Type the following command to compile and execute the quickstart:
$ mvn clean compile exec:java
|
Note
|
If you execute this command multiple times, you may see the following warning and exception, followed by a stacktrace. This is caused by a bug in Artemis that has been fixed, but not yet released. For details, see https://issues.apache.org/jira/browse/ARTEMIS-158. You can ignore this warning._
|
Investigate the Console Output
If the Maven command is successful, with the default configuration you will see output similar to this:
timestamp org.jboss.as.quickstarts.jms.HelloWorldJMSClient main
INFO: Attempting to acquire connection factory "jms/RemoteConnectionFactory"
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
timestamp org.jboss.as.quickstarts.jms.HelloWorldJMSClient main
INFO: Found connection factory "jms/RemoteConnectionFactory" in JNDI
timestamp org.jboss.as.quickstarts.jms.HelloWorldJMSClient main
INFO: Attempting to acquire destination "jms/queue/test"
timestamp org.jboss.as.quickstarts.jms.HelloWorldJMSClient main
INFO: Found destination "jms/queue/test" in JNDI
timestamp org.jboss.as.quickstarts.jms.HelloWorldJMSClient main
INFO: Sending 1 messages with content: Hello, World!
timestamp org.jboss.as.quickstarts.jms.HelloWorldJMSClient main
INFO: Received message with content Hello, World!
Optional Properties
The example provides for a certain amount of customization for the mvn:exec plug-in using the system properties.
Property |
Default value |
Description |
username |
quickstartUser |
This |
password |
quickstartPwd1! |
This |
connection.factory |
jms/RemoteConnectionFactory |
The name of the JMS |
destination |
jms/queue/test |
The name of the JMS |
message.count |
1 |
The number of JMS messages you want to produce and consume. |
message.content |
"Hello, World!" |
The content of the JMS |
java.naming.provider.url |
"localhost" |
This property allows configuration of the JNDI directory used to look up the JMS destination. This is useful when the client resides on another host. |
Restore the JBoss EAP Standalone Server Configuration
You can restore the original server configuration using either of the following methods.
-
You can run the
remove-jms.cliscript provided in the root directory of this quickstart. -
You can manually restore the configuration using the backup copy of the configuration file.
Restore the JBoss EAP Standalone Server Configuration by Running the JBoss CLI Script
-
Start the JBoss EAP server as described above.
-
Open a new terminal, navigate to the root directory of this quickstart, and run the following command, replacing
EAP_HOMEwith the path to your server:$ EAP_HOME/bin/jboss-cli.sh --connect --file=remove-jms.cliNoteFor Windows, use the EAP_HOME\bin\jboss-cli.batscript.
This script removes the test queue from the messaging subsystem in the server configuration. You should see the following result when you run the script.
The batch executed successfully
Restore the JBoss EAP Standalone Server Configuration Manually
When you have completed testing the quickstart, you can restore the original server configuration by manually restoring the backup copy the configuration file.
-
If it is running, stop the JBoss EAP server.
-
Replace the
EAP_HOME/standalone/configuration/standalone-full.xmlfile with the backup copy of the file.
Run the Quickstart in Red Hat JBoss Developer Studio or Eclipse
You can also start the server and deploy the quickstarts or run the Arquillian tests in Red Hat JBoss Developer Studio or from Eclipse using JBoss tools. For general information about how to import a quickstart, add a JBoss EAP server, and build and deploy a quickstart, see Use JBoss Developer Studio or Eclipse to Run the Quickstarts.
This quickstart consists of multiple projects, so it deploys and runs differently in Red Hat Developer Studio than the other quickstarts.
-
Make sure you add the authorized application user as described above.
-
Configure and start the JBoss EAP server in Red Hat Developer Studio:
-
Define a server runtime environment that uses the
standalone-full.xmlconfiguration file. -
Start the server defined in the previous step.
-
-
Outside of Red Hat Developer Studio, configure the JMS
testqueue by running the JBoss CLI commands as described above under Configure the Server. -
In Red Hat Developer Studio, right-click on the helloworld-jms project and choose Run As → Java Application. In the Select Java Application window, choose HellowWorldJMSClient - org.jboss.as.quickstarts.jms and click OK. The client output displays in the Console window. The output messages appear in the Console window.
-
Make sure you restore the JBoss EAP server configuration when you have completed testing this quickstart.
Debug the Application
If you want to debug the source code of any library in the project, run the following command to pull the source into your local repository. The IDE should then detect it.
$ mvn dependency:sources