Oracle WLS provides its own messaging system that fully implements the JMS specification; it also provides other configuration and programming options that go well beyond standard Enterprise-class messaging features. Here are the key components of Oracle WLS JMS Architecture:
- JMS Server: A JMS server is a management entity and container for JMS destination-related resources that reside on a single WLS instance. A WLS JMS Server instance can host zero or more JMS servers and can serve as a migration target for zero or more JMS servers.
- JMS Modules: JMS modules contain configuration resources such as queue and topic destinations, distributed destinations and connection factories. In WebLogic Server, these resources are configured inside the DOMAIN_HOME/config/jms directory.
- JMS Producers/Consumers: This is a piece of software that either produces messages to destinations or consumes messages from destinations.
- Persistent Store: This is used for storing the Data (Messages). It can be either a user defined Persistent Store or a Default Persistent store.
Here is a graphical view of the concepts exposed so far, which shows two JMS Servers each one containing a JMS module where JMS destinations are registered:
In order to create JMS resources, you need to perform a set of activities which include:
- Creating a JMS Server
- Creating a JMS Module
- Creating JMS Connection factories
- Creating JMS Destinations
In the following sections, we will create the first mandatory JMS resource, which is the JMS Server.
- Expand the Services option from the left menu and select Messaging | JMS Servers.
- Click New in the JMS Servers table. In the next screen, enter values for the following configuration parameters:
Specify the following mandatory settings:
- Name: The name of the JMS server.
- Persistent Store: A JMS store can be file-based or database. Database is usually a bit slower, but can take advantage of high-availability or failover solutions offered by the database. A value of “none”, means that the JMS server will use the default persistent store that is configured on each targeted WLS instance.
If you don’t want to rely on the default Persistent Store, hit the “Create a New Store” button. This will continue navigation to another screen where you can select File Store or JDBC Store.
- If you selected JDBC Store, in the next screen you need to select a JDBC data source or configure a new JDBC data source for the store.
- If you selected File Store, in the next screen you need to enter the path name for your storage (mind it, the directory must exist on your system, so be sure to create it before completing this step).
Complete this section by targeting a JMS server to an Oracle WLS server:
Click Save to complete the JMS Server creation.
In order to create JMS resources such as queues, topics and connection factories you need to create, at first, a JMS Module which acts as a container for these resources.
JMS modules are application-related definitions that are independent of the domain environment.
You create and manage JMS resources either as System modules or as Application modules.
- JMS System modules are typically configured using the Administration Console or the WebLogic Scripting Tool (WLST).
- JMS Application modules are a WebLogic-specific extension of JEE modules and can be deployed along with a JEE application.
Let’s see at first how to create a new JMS System module. In order to do that, perform the following steps:
- Expand the Services label from the left menu and select Messaging | JMS Modules.
- Click New to create a new JMS System Module. In the next screen, choose a Name for the JMS System Module. You can optionally specify a Name and a Location where JMS file descriptors will be saved.
Module file descriptors are pretty useful as a template if you want to deploy your JMS resource at application level
Click Next. In the following screen choose the target servers for your JMS Module:
Check the servers where you want to target your JMS module and click Save.
The last screen contains a check box which lets you add JMS resources (such as JMS Queues) to your newly created JMS System Module.
If you want to associate JMS resources to the module check the above option and click Finish.
In order to create a new JMS resource you need to enter into the JMS module Configuration screen as depicted by the following picture: (If you are arriving from a new JMS module creation, you will be automatically into the JMS module configuration window, otherwise select from the left menu Services | Messaging | JMS Modules and click on your JMS Module)
Click New to add a new resource to the JMS Module. We will show at first how to create a Connection Factory and then how to create a JMS destination.
Connection factories are resources that enable JMS clients to create JMS connections.
From the JMS Module screen, click New and select Connection Factory from the list of resources.
Click Next. In the following screen enter the Connection factory properties:
You need to provide, at least, the mandatory Name and JNDI binding for your Connection factory. Once done, click Finish. At the top of the page, a message will indicate that you have successfully created the Connection Factory which will be mentioned in the Summary view of your JMS resources.
JMS configuration resources such as destinations and connection factories are stored outside of the domain configuration file (config.xml) as module descriptor files of an application. You can find them in the config/jms folder of your domain.
From the JMS module Configuration screen(Services | Messaging | JMS Modules | [your module]) click on New and select a new Queue from the options:
Click Next. In the following screen enter the mandatory destination Name and its JNDI Name:
Click Next. On the following screen, you will be able to create a new Subdeployment for the system module resource.
A Subdeployment for JMS destinations is a mechanism by which queues, topics and connection factories are grouped and targeted to a single JMS server. By using Subdeployments, you will be able to re-locate a group of queues with a connection factory that is targeted to a specific JMS server, by associating the queues with the connection factory’s Subdeployment.
Therefore, if you choose to create a new Subdeployment, in the next screen you will be asked to choose a name to identify your Subdeployment:
Click Ok and you will be redirected to the earlier step with the new Subdeployment now selected, and your JMS Server as the target:
Click Finish. The JMS Summary of Resources will show your new Queue resource.
You can continue creating new JMS destinations, such as Topics, by clicking “New” again and following the same procedure that we have just showed. Be sure to assign also the other JMS destinations to the same Subdeployment unit.
JMS Resources can be packed along with your application just like we did for JDBC resources. The procedure stays the same as for the data sources except that the JMS module needs to be named with the –jms.xml suffix; for example, module-name-jms.xml. Here’s an Eclipse view of an Enterprise project which contains a JMS application module:
And here’s an example module-jms.xml file which will be placed at the root of your EAR file:
The JMS resource needs, in turn, to be enlisted in weblogic-application.xml
Next, add a resource reference to all Java EE modules which are using the JMS resource, just like we did for the data source (See section “Deploying a data source at application level” in Chapter 3). The only notable difference is the resource type referenced, which should match the corresponding java JMS class; for example if you were to add a QueueConnection factory:
On the other hand, a JMS queue can be referenced using a javax.jms.Queue res-type: