This tutorial shows how to create and configure Java Message Service (JMS) servers, queues, and topics in an instance of Oracle WebLogic Server 12c.
Approximately 1/2 hour
A JMS server implements the JMS infrastructure on WebLogic server. Destinations, either queues or topics, can be targeted to a WebLogic server instance that has a JMS server configured.
This tutorial covers creating and configuring a JMS server, a queue, and a topic. It then shows how to use the provided web application to post messages to the queue and topic. It also shows how to monitor the queue and topic by using the Oracle WebLogic Server 12c (12.1.1) administration console.
The following is a list of software requirements:
Before starting this tutorial, you should have completed the Oracle by Example tutorials titled Oracle WebLogic Server 12c: Installing WebLogic Server and Creating a Domain and Oracle WebLogic Server 12c: Configuring Managed Servers.
To start the administration server and the dizzy1 managed server of the domain, perform the following steps:
. |
If the administration server of the domain is not already running, it needs to be started. To start it, in a Terminal window, navigate to the domain directory, and enter the command: $ ./startWebLogic.sh
When prompted for a username and password, enter the credentials of the domain administrator.
|
---|---|
. |
The managed server dizzy1 should also be running. If it is not already running, start it. In another Terminal window, navigate to the domain directory, then cd into the bin subdirectory. Enter the command: $ ./startManagedWebLogic.sh dizzy1 http://host01.example.com:8001
This runs the script to start the managed server named dizzy1.
Also notice the argument that gives the URL of the domain's administration server:
Note: Use the host name and port of the administration server of your domain.
When prompted for a username and password, enter the credentials of the domain administrator.
|
To create and configure a JMS Server by using the administration console, perform the following steps:
. |
After the servers are up and running, access
the WebLogic Server administration console.
Open a web browser and enter its URL:
In this tutorial, that is: http://host01.example.com:8001/console Note: Use the host name and port of the administration server of your domain. On the Welcome screen, log in using the Username and Password entered to start the servers.
|
---|---|
. |
Creating a JMS Server is a change to the domain's configuration, so the configuration must first be locked. In the Change Center, click the Lock & Edit button.
|
. |
In the administration console under Domain Structure, expand Services (by clicking the + sign next to it). Then expand Messaging. Then click JMS Servers.
|
. |
On the right, the Summary of JMS Servers section appears. Above the JMS Servers table, click the New button.
|
. |
In the Create a New JMS Server screen, enter the Name of the JMS Server as dizzyworldJMSServer. Leave the Persistent Store as (none). Then click Next.
|
. |
On the next screen, use the Target drop-down list to select dizzy1. Then click Finish.
The message "JMS Server created successfully." is displayed. Note: If in your domain, dizzy1 is part of a cluster, you may have noticed you can select either dizzy1 or dizzy1 (migratable). What the "migratable" option means is that the JMS Server, which can only be targeted to one instance of WebLogic server, can be migrated to another instance of WebLogic server in the cluster in case of failure.
|
. |
In the Change Center click the Activate Changes button.
The message "All changes have been activated. No restarts are necessary." is displayed.
|
To create and configure a JMS queue and topic by using the administration console, perform the following steps:
. |
Lock the configuration again. In the Change Center, click the Lock & Edit button.
|
---|---|
. |
In the administration console under Domain Structure, click JMS Modules (under Services and Messaging).
|
. |
On the right, the JMS Modules section appears. Above the JMS Modules table, click the New button.
|
. |
On the Create JMS System Module screen, enter the Name as dizzyworldModule. Also enter the Descriptor File Name as dizzyworldModule. Leave Location in Domain blank. Then click Next.
|
. |
On the next screen, select the check box next to dizzy1. Then click Next.
Note: If in your domain, dizzy1 is not part of a cluster, the target screen will look different. Still select dizzy1.
|
. |
On the next screen, select the check box next to Would you like to add resources to this JMS system module? Then click Finish.
The message "The JMS module was created successfully." is displayed.
|
. |
Under the Settings for dizzyworldModule, click the Subdeployments tab.
|
. |
Above the Subdeployments table, click the New button.
|
. |
On the Create a New Subdeployment screen, enter the Subdeployment Name as dizzysubmodule. Then click Next.
|
. |
On the next screen, select the check box next to dizzyworldJMSServer. Then click Finish.
The message "Subdeployment created successfully." is displayed. Note: As before, if in your domain you do not have a cluster or you have different servers defined, the target screen will look different.
|
. |
Click the Configuration tab.
|
. |
Under the Settings for dizzyworldModule, above the Summary of Resources table, click the New button.
|
. |
For the type of resource, select the Queue radio button. Then click Next.
|
. |
On the next screen, enter the Name as dizzyworldQueue. Also enter the JNDI Name as dizzyworldQueue. Leave the Template as None. Then click Next.
|
. |
On the next screen, use the Subdeployments drop-down list to select dizzysubmodule. After that is selected, the Targets area fills in to show that the target is the JMS Server dizzyworldJMSServer. Click Finish.
The message "The JMS Queue was created successfully" is displayed.
|
. |
Under the Settings for dizzyworldModule, above the Summary of Resources table, click the New button again.
|
. |
This time, for the type of resource, select the Topic radio button. Then click Next.
|
. |
On the next screen, enter the Name as dizzyworldTopic. Also enter the JNDI Name as dizzyworldTopic. Leave the Template as None. Then click Next.
|
. |
On the next screen, use the Subdeployments drop-down list to select dizzysubmodule. After that is selected, the Targets area fills in to show that the target is the JMS Server dizzyworldJMSServer. Click Finish.
The message "The JMS Topic was created successfully" is displayed.
|
. |
In the Change Center click the Activate Changes button.
The message "All changes have been activated. No restarts are necessary." is displayed.
|
. |
Under Domain Structure, expand Environment and then click Servers. In the Servers table, click the server dizzy1.
|
. |
In the Settings for dizzy1, under the Configuration tab and the General subtab, click the link View JNDI Tree.
|
. |
The JNDI tree opens in a new browser window (or tab). Notice that dizzyworldQueue and dizzyworldTopic appear in the JNDI tree. Note: Other entries in the JNDI tree of your server can be very different from what is shown here. It all depends upon what resources your server has.
|
To customize how queues and topics are displayed in the administration console, perform the following steps:
. |
In the administration console under Domain Structure, go back under Services, then Messaging, and click JMS Modules. In the JMS Modules table, click dizzyworldModule.
|
---|---|
. |
In the Summary of Resources table, click dizzyworldQueue.
|
. |
Under the Settings for dizzyworldQueue, click the Monitoring tab.
|
. |
Click Customize this table in the Monitoing screen.
|
. |
Select Consumers High and Consumers Total from the Chosen column and click the left arrow to move those items to Available. This will decrease the number of columns in the table. Then click the Apply button.
|
. |
Notice that there are fewer columns displayed for the queue in the Destinations table now.
|
. |
Customizing the topic display is accomplished in the same way. Under Domain Structure, go back under Services, then Messaging, and click JMS Modules. In the JMS Modules table, click dizzyworldModule. In the Summary of Resources table, click dizzyworldTopic. Under the Settings for dizzyworldTopic, click the Monitoring tab. Click Customize this table in the Monitoing screen. Select Messages Total from the Available column and click the right arrow to move this item to Chosen. This will increase the number of columns in the table. Then click the Apply button.
|
. |
Notice that there are more columns displayed for the topic in the Destinations table now.
|
To test the JMS queue and topic with the supplied web application, perform the following steps:
. |
Download the test_jms.zip file to the machine where your WebLogic Server domain and servers are. Extract the file contents to a local drive. In this tutorial, the files are extracted into the /home/oracle/jmsobe directory. The zip file contains two files:
|
---|---|
. |
Open a new Terminal window and navigate
to the /server/bin directory under
the WebLogic installation directory.
In this tutorial, that is:
Then run the setWLSEnv.sh script as follows: $ source setWLSEnv.sh This will set the PATH and the CLASSPATH so the WLST deployment script can be executed.
|
. |
Next navigate to the directory where the messaging.war file resides. In this tutorial, that directory is: /home/oracle/jmsobe. Before running the supplied WLST script, deploy_testjms.py, you may need to edit it. The first line of the script uses the connect() command. The first argument of that command is the domain administrator's username, the second argument is that user's password, and the third argument is the host and port of the administration server of the domain. Make sure the values for these arguments are correct for your domain before running this script. Make any changes required to the script, and save the file.
|
. |
Run the deploy_testjms.py script to deploy the web application in the messaging.war file and target it to the dizzy1 server. Do this by entering the following command: $ java weblogic.WLST deploy_testjms.py
You should see a message that the deploy operation has succeeded. Note: You can ignore the warning about Context.close(). That warning is always displayed when running a WLST script and is not an issue.
|
. |
To verify the deployment was successful, go to the administration console, and under Domain Structure, click Deployments. Then in the Deployments table, find Messaging with the "Active" State.
|
. |
To use the deployed application, in another web browser, enter the host and port for the dizzy1 managed server, followed by /messaging.
In this tutorial, the URL entered is:
When the application comes up, enter text in either of the two Message fields and click the button below that field. A message entered in the top field is sent to the queue. A message entered in the bottom field is published to the topic.
After a button is clicked, on the next screen, click the Back To Home Page link to be able to do it again. Post as many messages as you would like to the queue and the topic. Remember how many messages you post to each destination.
|
To monitor the JMS queue and topic, perform the following steps:
. |
Go back to the administration console. Under Domain Structure, go back under Services, then Messaging, and click JMS Modules. In the JMS Modules table, click dizzyworldModule.
|
---|---|
. |
In the Summary of Resources table, click dizzyworldQueue.
|
. |
Under the Settings for dizzyworldQueue, click the Monitoring tab.
|
. |
In the Destinations table, notice the entries next to dizzyworldModule!dizzyworldQueue. You should see the number of messages you sent to the queue in Messages Total.
|
. |
To monitor the topic, under Domain Structure, go back under Services, then Messaging, and click JMS Modules. In the JMS Modules table, click dizzyworldModule. In the Summary of Resources table, click dizzyworldTopic. Under the Settings for dizzyworldTopic, click the Monitoring tab. In the Destinations table, notice the entries next to dizzyworldModule!dizzyworldTopic. You should see the number of messages you published to the topic in Messages Total.
|
In this tutorial, you learned how to:
Copyright © 2011, Oracle and/or its affiliates. All rights reserved | |