Sie sind auf Seite 1von 15

Lab 10

JMS Java Message Service


In this exercise you will create a JMS Uniform Distributed Queue spanning the two existing Managed
Servers, use different configurations for message load balancing and run tests with some provided Java
clients.

Note:
You need to have Node Manager, AdminServer and the two Managed servers running.

You can start them by using the following approach:

- start the Admin Server by using the shortcut on the desktop: start labs_domain
AdminServer

- start the Node Manager by using the shortcut on the desktop: start labs_domain
Node Manager

- start ms_1 and ms_2 by using the admin console.

In Administration Console(http://wins-vbox:7001/console/) go to Domain Structure and click


on JMS Servers

Create a new JMS Server and set JMSServer_ms1 as its name. Dont create a Persistent Store
for it, the messages will be kept only in memory

2|Page
Assign this JMS Server to Managed Server ms_1

Create a second JMS Server (JMSServer_ms2) and assign it to the second managed server ms_2

Go to Domain Structure and click on JMS Modules

3|Page
Create a new JMS Module, give it a name and click Next

Assign the module to the existing WebLogic cluster labCluster

In order to create the JMS Connection factory and queue, check the option for adding the
resources and then click Finish

4|Page
Create a New resource and choose Connection Factory as resource type

Give it a name and set the JNDI name to jms/myCF

5|Page
Note:
If you choose another JNDI name than jms/myCF, you will need to change the JMS
clients Java code and configuration files which are used later during this exercise!

Accept the default targeting and finish the step. By default, the Connection factory takes the
targets of its parent the JMS Module. In our case, the target is the WebLogic cluster
labCluster.

Create a New resource in the same myJMSModule and choose the type Distributed Queue

6|Page
Give it a name and set jms/DistributedQueue as JNDI name

Note:
If you choose another JNDI name than jms/DistributedQueue, you will need to change
the JMS clients Java code and configuration files which are used later during this
exercise!

Accept the default (inherited) targets and Finish the step

7|Page
You should have the following two resources in your JMS Module

To check that the JNDI names are correct and visible to both managed servers, go to Managed
Server ms_1 and click on View JNDI Tree link. A new browser tab or window will open with all
the global JNDI names registered with that particular server

8|Page
Check for the existence of both jms/myCF and jms/DistributedQueue

Do the same for Managed Server ms_2

Tests

Go to myJMSModule and click on distributed queue resource

9|Page
and then to Monitoring tab

This is the place where you can see the distributed queue deployed on the two managed
servers, part of the same cluster. Click on the link above the table to customize the table to
include more information

Select the five column choices about messages and copy them on the right side

Dont forget to Apply the changes

10 | P a g e
Now the table should look like the following

Go to VBox Linux image and click on labs_domain: JMS Message Producer icon from Desktop.
This is a Java client which will connect to the server and send 10 JMS messages to the
distributed queue

A new terminal will be launched and you should see the following output

11 | P a g e
Now go back to AdminConsole and refresh the page with Monitoring tab of the distributed
queue. You should see all 10 JMS messages arrived in one of the JMS server

Launch from Linux Desktop the labs_domain: JMS Queue Receiver client corresponding to
the managed server where JMS messages arrived. The JMS client will connect to the server and
consume those messages

or

12 | P a g e
Going back to Admin Console, you will see that messages have been consumed by one
Consumer

Because all the 10 messages were sent by the same client (JMS Message Producer) in one transaction,
all the messages were sent to the same server. The reason for this is the Server Affinity setting which
is activated by default to avoid creating new connections and instantiating new resources for each and
every message sent by the same client.

Go to myJMSModule and click on the Connection Factory myCF

13 | P a g e
and then on Load Balance tab

Unselect Server Affinity option and Save the new setting

Now run again the JMS Message Producer client and then check the Admin Console again. You
should see that the 10 messages were equally split on the two servers in the cluster

Run again the JMS Queue Receiver to consume the messages. Because the client will be
connected to one of the servers, it will consume only the 5 messages found on that server
(check the messages IDs)

14 | P a g e
Run the other receiver client to consume the rest of 5 messages from the other server

Shut down all the labs_domain running severs and the node manager.

15 | P a g e

Das könnte Ihnen auch gefallen