Bookmark this page

Lab: Configuring the Messaging Subsystem

Configure JMS resources for a test applications to communicate by using JMS.

Resources
Files: /opt/domain
/home/student/AD248/labs/messaging-lab
/tmp/messaging-client.war
/tmp/messaging-mdb.jar
Application URL: http://172.25.250.10:8080/mdb-client/queue

Outcomes

You should be able to configure the messaging subsystem of a JBoss EAP managed domain to create a connection factory and a queue in a managed domain to use with a test application.

Use the following command to prepare the environment:

[student@workstation ~]$ lab start messaging-review

A JBoss EAP administrator has set up a managed domain with two host controllers running on servera and serverb machines. The domain controller runs on the workstation machine. The domain and host configuration files are stored in the /opt/domain directory on all three machines.

This lab uses two applications:

  • mdb-client.war is the message producer: a web application that accepts text from the user and publishes as JMS messages properties and body.

  • helloworld-mdb.jar is the message consumer: an application with a Message-Driven Bean (MDB) that consumes JMS messages and shows the message properties and body in the JBoss EAP server log.

Both test applications use the following JMS resources:

  • A connection factory called custom with JNDI address java:/jms/CustomCF. It should point to the ActiveMQ in-vm connector.

  • A queue called TestQueue with JNDI address java:/jms/queue/AD248TestQueue. There is no need to configure any message settings for this queue.

You must deploy the applications to the Group1 server group, which uses the full-ha clustered profile. The lab start command configures the firewall rules to match default JBoss EAP settings for this profile.

Make sure that all application server instances in the Group1 server group are consuming messages. This ensures that message processing is distributed amongst the JBoss EAP hosts.

Instructions

  1. Start the JBoss EAP managed domain. All JBoss EAP processes should be owned by the jboss user.

    1. Start the domain controller on the workstation machine by using /opt/domain as the base directory and host-master.xml as the host configuration file.

      [student@workstation ~]$ sudo -u jboss /opt/jboss-eap-7.4/bin/domain.sh \
      -Djboss.domain.base.dir=/opt/domain \
      --host-config=host-master.xml
      ...output omitted...
    2. Start the host controller on servera. Open a new terminal window on the workstation machine and run the following command:

      [student@workstation ~]$ ssh -t jboss@servera /opt/jboss-eap-7.4/bin/domain.sh \
      -Djboss.domain.base.dir=/opt/domain/ \
      -Djboss.domain.master.address=172.25.250.9 \
      -bprivate=172.25.250.10 \
      --host-config=host-slave.xml
      ...output omitted...
    3. Start the host controller on serverb. Open a new terminal window on the workstation machine and run the following command:

      [student@workstation ~]$ ssh -t jboss@serverb /opt/jboss-eap-7.4/bin/domain.sh \
      -Djboss.domain.base.dir=/opt/domain/ \
      -Djboss.domain.master.address=172.25.250.9 \
      -bprivate=172.25.250.11 \
      --host-config=host-slave.xml
      ...output omitted...
    4. Verify that both host controllers connect to the domain controller and form a managed domain. In the workstation terminal window, verify that the logs show that both servera and serverb registered to the domain controller.

      ...output omitted...
      [Host Controller] ... Registered remote slave host "servera" ...
      [Host Controller] ... Registered remote slave host "serverb" ...
  2. Verify that all three server instances connected to form an ActiveMQ cluster.

    The managed domain contains another server group with two more server instances. Because this group uses the full-ha profile, it has the same clustering parameters as Group1. Its ActiveMQ embedded server instances join the same messaging cluster.

    Set the root logger to use the INFO log level so that applications logs are shown.

    1. In a new terminal on the workstation machine, connect to the management CLI.

      [student@workstation ~]$ sudo -u jboss /opt/jboss-eap-7.4/bin/jboss-cli.sh \
      --connect --controller=172.25.250.9:9990
      [domain@172.25.250.9:9990 /]
    2. Increase the log level by configuring the root logger to use the INFO logging level.

      [domain@172.25.250.254:9990 /] /profile=full-ha/subsystem=logging\
      /root-logger=ROOT:write-attribute(name=level,value=INFO)
      ...output omitted...
      "outcome" => "success",
      ...output omitted...
    3. Enter the messaging-activemq subsystem on any of the running server instances. The following command uses the servera.1 server.

      [domain@172.25.250.9:9990 /] cd /host=servera/server=servera.1/\
      subsystem=messaging-activemq
    4. Verify that the topology attribute of the cluster-connection object shows all four server instances in the domain.

      [domain@172.25.250.9:9990 subsystem=messaging-activemq] ./server=default\
      /cluster-connection=my-cluster:read-attribute(name=topology)
      ...output omitted...
          "result" => "topology on Topology@120fd71c[ ... port=8080&host=172-25-250-10, address=jms, server=ActiveMQServerImpl::serverUUID= ... ]]:
              ca7bf71d-9902-11ee-a559-52540000fa0a => TopologyMember[id = ca7bf71d-9902-11ee-a559-52540000fa0a, connector=Pair[ ... port=8080&host=172-25-250-10, b=null] ... ]
              cd34fc60-9902-11ee-a3e9-52540000fa0b => TopologyMember[id = cd34fc60-9902-11ee-a3e9-52540000fa0b, connector=Pair[ ... port=8080&host=172-25-250-11, b=null] ... ]
              nodes=2 members=2"
      }

      Note that each TopologyMember resource has a different id and points to a different http-acceptor port and host pair.

  3. Create the JMS resources on the full-ha profile.

    1. Within the messaging-activemq subsystem of the full-ha profile, create a pooled connection factory called custom by using java:/jms/CustomCF as the JNDI name.

      [domain@172.25.250.9:9990 subsystem=messaging-activemq] cd /profile=full-ha/\
      subsystem=messaging-activemq/server=default
      [domain@172.25.250.9:9990 server=default] ./pooled-connection-factory=\
      custom:add(connectors=[in-vm], entries=[java:/jms/CustomCF])
      ...output omitted...
      "outcome" => "success",
      ...output omitted...
    2. Create a queue called TestQueue with java:/jms/queue/AD248TestQueue as the assigned JNDI name.

      [domain@172.25.250.9:9990 server=default] ./jms-queue=TestQueue:add(\
      entries=[java:/jms/queue/AD248TestQueue])
      ...output omitted...
      "outcome" => "success",
      ...output omitted...
  4. Deploy the producer and consumer applications.

    1. Deploy the message producer application to the Group1 group.

      [domain@172.25.250.9:9990 server=default] deploy \
      /tmp/mdb-client.war --server-groups=Group1
    2. Deploy the message consumer application to Group1. Use the CLI to deploy the /tmp/messaging-mdb.jar consumer bean:

      [domain@172.25.250.9:9990 server=default] deploy \
      /tmp/helloworld-mdb.jar --server-groups=Group1
    3. Verify that both deployments were successful. Run the following command with servera and serverb to verify the servers logs the following output:

      [student@workstation ~]$ ssh servera \
      tail /opt/domain/servers/servera.1/log/server.log
      ...output omitted...
      ... Deployed "mdb-client.war" (runtime-name : "mdb-client.war")
      ...output omitted...
      ... Deployed "helloworld-mdb.jar" (runtime-name : "helloworld-mdb.jar")
      ...output omitted...
  5. Publish test messages and verify that both Group1 server instances consumed messages. Also verify that the embedded messaging servers in both servera.1 and serverb.1 server instances received messages to their local queues.

    1. In a new terminal window, send an HTTP request to the server to create several messages. Use the count parameter to send five messages with the same content.

      [student@workstation ~]$ curl --data "count=5" --data "label=first" \
      --data "message=test message body" \
      http://172.25.250.10:8080/mdb-client/queue
      ...output omitted...
    2. Verify that the servera.1 server logs contain entries similar to the following. The message distribution between servers you see might differ. However, both server instances from Group1, servera.1 and serverb.1, should receive messages.

      Server instances from Group2 should not consume messages because they have no consumer application deployed. Only servera.1 and serverb.1 should have any activity in their local queues.

      [student@workstation ~]$ ssh servera tail \
      /opt/domain/servers/servera.1/log/server.log
      ... INFO ... (Thread-8 ...) Received Message from queue: test message body
      ... INFO ... (Thread-8 ...) Message Properties: Copy #5 [first]
      ... INFO ... (Thread-8 ...) Message Body: test message body
      ... INFO ... (Thread-6 ...) Received Message from queue: test message body
      ... INFO ... (Thread-6 ...) Message Properties: Copy #1 [first]
      ... INFO ... (Thread-6 ...) Message Body: test message body
      ... INFO ... (Thread-7 ...) Received Message from queue: test message body
      ... INFO ... (Thread-7 ...) Message Properties: Copy #3 [first]
      ... INFO ... (Thread-7 ...) Message Body: test message body

      Run the same command on serverb

      [student@workstation ~]$ ssh serverb tail \
      /opt/domain/servers/serverb.1/log/server.log
      ... INFO ... (Thread-6 ... ) Received Message from queue: test message body
      ... INFO ... (Thread-6 ... ) Message Properties: Copy #4 [first]
      ... INFO ... (Thread-6 ... ) Message Body: test message body
      ... INFO ... (Thread-5 ... ) Received Message from queue: test message body
      ... INFO ... (Thread-5 ... ) Message Properties: Copy #2 [first]
      ... INFO ... (Thread-5 ... ) Message Body: test message body

      Note

      Because JBoss EAP runs MDB instances in parallel, it is normal for messages to be consumed out-of-order.

    3. Verify that messages are queued to different JBoss EAP server instances.

      In the management CLI terminal window, verify that the message counters on servera.1 match the following:

      [domain@172.25.250.9:9990 server=default] /host=servera\
      /server=servera.1/subsystem=messaging-activemq/server=default\
      /jms-queue=TestQueue:read-attribute(name=messages-added)
      {
          "outcome" => "success",
          "result" => 3L
      }
    4. Verify that the message counters on serverb.1 match the following:

      [domain@172.25.250.9:9990 server=default] /host=serverb\
      /server=serverb.1/subsystem=messaging-activemq/server=default\
      /jms-queue=TestQueue:read-attribute(name=messages-added)
      {
          "outcome" => "success",
          "result" => 2L
      }
  6. Clean up the lab environment.

    1. Stop the secondary hosts by issuing the shutdown command to each host in the managed domain.

      [domain@172.25.250.9:9990 server=default] /host=servera:shutdown
      [domain@172.25.250.9:9990 server=default] /host=serverb:shutdown
    2. Stop the domain controller by issuing the shutdown command to the primary host.

      [domain@172.25.250.9:9990 server=default] /host=master:shutdown

Evaluation

As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.

[student@workstation ~]$ lab grade messaging-review

Finish

As the student user on the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish messaging-review

Revision: ad248-7.4-18a9db2