The remote-helloworld-mdb
quickstart demonstrates the use of JMS and EJB Message-Driven Bean in {productName} with a remote broker.
The remote-helloworld-mdb
quickstart demonstrates the use of JMS and EJB Message-Driven Bean in {productNameFull} with a remote Apache Artemis broker.
This project uses two JMS resources on a remote broker:
-
A queue named
HELLOWORLDMDBQueue
bound in JNDI asjava:/queue/HELLOWORLDMDBQueue
-
A topic named
HELLOWORLDMDBTopic
bound in JNDI asjava:/topic/HELLOWORLDMDBTopic
You can run Apache Artemis broker locally using docker or podman:
$ docker run --rm --name artemis -e AMQ_USER=admin -e AMQ_PASSWORD=admin -p8161:8161 -p61616:61616 -e AMQ_DATA_DIR=/home/jboss/data quay.io/artemiscloud/activemq-artemis-broker-kubernetes
You can access the console of Apache Artemis at the URL: http://localhost:8161/console with admin/admin to authenticate.
You configure the JMS connection factory to the remote broker by running JBoss CLI commands. For your convenience, this quickstart batches the commands into a configure-remote-broker.cli
script provided in the root directory of this quickstart.
-
Before you begin, make sure you do the following:
-
Back up the {productName} standalone server configuration as described above.
-
Start the {productName} server with the standalone full profile as described above.
-
-
Review the
configure-remote-broker.cli
file in the root of this quickstart directory. This script adds thetest
queue to themessaging-activemq
subsystem in the server configuration file. -
Open a new terminal, navigate to the root directory of this quickstart, and run the following command, replacing {jbossHomeName} with the path to your server:
$ {jbossHomeName}/bin/jboss-cli.sh --connect --file=configure-remote-broker.cli
NoteFor Windows, use the {jbossHomeName}\bin\jboss-cli.bat
script. -
You should see the following result when you run the script:
"outcome" => "success", "response-headers" => {"process-state" => "reload-required"}
-
Stop the {productName} server.
After stopping the server, open the {jbossHomeName}/standalone/configuration/standalone-full.xml
file and review the changes.
The following testQueue
jms-queue was configured in the configuration of the messaging-activemq
subsystem.
<remote-connector name="artemis" socket-binding="remote-artemis"/>
<pooled-connection-factory name="RemoteConnectionFactory" entries="java:jboss/RemoteConnectionFactory java:jboss/exported/jms/RemoteConnectionFactory" connectors="artemis" user="admin" password="admin" enable-amq1-prefix="false"/>
The application will be running at the following URL: http://localhost:8080/{artifactId}/.
Look at the {productName} console or Server log and you should see log messages like the following:
INFO [class org.jboss.as.quickstarts.mdb.HelloWorldQueueMDB] (Thread-9 (ActiveMQ-client-global-threads-1189700957)) Received Message from queue: This is message 1
INFO [class org.jboss.as.quickstarts.mdb.HelloWorldQueueMDB] (Thread-6 (ActiveMQ-client-global-threads-1189700957)) Received Message from queue: This is message 2
INFO [class org.jboss.as.quickstarts.mdb.HelloWorldQueueMDB] (Thread-7 (ActiveMQ-client-global-threads-1189700957)) Received Message from queue: This is message 3
INFO [class org.jboss.as.quickstarts.mdb.HelloWorldQueueMDB] (Thread-5 (ActiveMQ-client-global-threads-1189700957)) Received Message from queue: This is message 4
INFO [class org.jboss.as.quickstarts.mdb.HelloWorldQueueMDB] (Thread-4 (ActiveMQ-client-global-threads-1189700957)) Received Message from queue: This is message 5
../shared-doc/run-arquillian-integration-tests-with-server-distribution.adoc ../shared-doc/undeploy-the-quickstart.adoc ../shared-doc/restore-standalone-server-configuration.adoc
This script removes the remote broker connection from the messaging-activemq
subsystem and restore the default
internal broker. You should see the following result when you run the script:
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
Note
|
The Arquillian integration tests expect a running Apache Artemis broker, so make sure you have started the broker before you begin. |
$ oc run artemis --env AMQ_USER=admin --env AMQ_PASSWORD=admin --image=quay.io/artemiscloud/activemq-artemis-broker-kubernetes --port=61616 --expose=true
This will create a broker instance named artemis
on OpenShift that can be accessed on the port 61616
on the service artemis
with the account admin/admin.