WLDF generating JMS Message notifications

This post describes a simple usage of how we can leverage the WLDF functionality with JMS feature. This post would show how WLDF can generate notifications in the form of JMS messages and sends it to message Queue which can be consumed by the JMS consumer.

Before starting the configuration , we would require a JMS Queue setup. Follow the below link to create one.


1. Login into the WebLogic Administration Console and navigate to Diagnostic → Diagnostic Module.

Create a WLDF (Diagnostic) module.

2. Click on the created WLDF module.

NOTE: There are two types o RunTime MBeans.  DomainRuntime Mbean and ServerRuntime Mbean.

DomainRuntime Mbean provides access to the Domain Wide configuration and is available only for the Admin Server.

When connecting to Managed Server, the root would be ServerRuntime MBean and DomainRuntime Mbean is not available

The below post depicts the access to DomainRuntime Mbean.

Navigate to the ‘Create Metrics’ → New → Specify the Metric Collection Properties details by selecting on which type of Mbean you want to configure the Metrics. → Select DomainRuntime

3. Select the Mbean you want to collect metrics for. For demo we would select ‘weblogic.management.runtime.JVMRuntimeMBean’ → Specify which attribute of the Mbean you want to monitor. For instance select ‘HeapSizeMax’.

4. Select the server instance which you want to monitor. Click finish and the collection metrics is created.

5. Now create Watch and Notifications.

The Watch and Notification system can be used to create automated monitors that observe specific diagnostic state and send notifications based on configured rules.

Watch:- It is basically used to monitor the Mbean attributes.

Notifications: There are the events which are triggered based on the values set in the watch. There can be different kind of alerts like SNMP alerts, JMS Messages, JMX notifications etc.

We would be selecting JMS Messages from the notifiers list.

6. Specify the Queue JNDI name and the Connection Factory JNDI name which would be notified when the Watch events are triggered.

7. Once the notification is created. Create a watch to monitor the attributes of the Mbean.

8. Click on the ‘Add Expressions’ to specify the rules for the watch. There can be a set of rules monitoring different attributes.

Here we would monitor the HeapSizeMax attribute of ‘weblogic.management.runtime.JVMRuntimeMBean for demo.

9. Select DomainRuntime from the drop down → Click next and select ”weblogic.management.runtime.JVMRuntimeMBean’ from the drop down list → Select the instance of the server from the drop down list.

10.Select the attribute , you want to monitor. For example HeapSizeMax and specify a value for that rule. Click Next.

Note: Click on combine tab, if you want to have a set of rules for the watch expression.

11. Select ‘Use an automatic reset alarm’ that would reset the notification alarms automatically.

12. Select the JMS Notifier from the left side list so that we can associate the Notifier with the watch created, click finish.

13. Target the WLDF to any of the servers whose MBeans are monitored.

Note: The default polling interval of the Mbean attribute is ‘300000’ milliseconds. We can reconfigure it as per our requirements.

13. Now check the server logs or the server console and you can see the alerts being triggered.

14. Compile and execute the below QueueReceiver.java program to receive the notifications in the form of JMS Messages and listening to queue ‘Queue’.



import java.util.Hashtable;

import javax.jms.*;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingException;

public class QueueReceive implements MessageListener


public final static String JNDI_FACTORY=”weblogic.jndi.WLInitialContextFactory”;

public final static String JMS_FACTORY=”CF1″;

public final static String QUEUE=”Queue1″;

private QueueConnectionFactory qconFactory;

private QueueConnection qcon;

private QueueSession qsession;

private QueueReceiver qreceiver;

private Queue queue;

private boolean quit = false;

public void onMessage(Message msg)


try {

String msgText;

if (msg instanceof TextMessage) {

msgText = ((TextMessage)msg).getText();

} else {

msgText = msg.toString();


System.out.println(“Message Received: “+ msgText );

if (msgText.equalsIgnoreCase(“quit”)) {

synchronized(this) {

quit = true;

this.notifyAll(); // Notify main thread to quit



} catch (JMSException jmse) {

System.err.println(“An exception occurred: “+jmse.getMessage());



public void init(Context ctx, String queueName)

throws NamingException, JMSException


qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);

qcon = qconFactory.createQueueConnection();

qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

queue = (Queue) ctx.lookup(queueName);

qreceiver = qsession.createReceiver(queue);




public void close()throws JMSException






public static void main(String[] args) throws Exception {

if (args.length != 1) {

System.out.println(“Usage: java examples.jms.queue.QueueReceive WebLogicURL”);



InitialContext ic = getInitialContext(args[0]);

QueueReceive qr = new QueueReceive();

qr.init(ic, QUEUE);

System.out.println(“JMS Ready To Receive Messages (To quit, send a \”quit\” message).”);

synchronized(qr) {

while (! qr.quit) {

try {


} catch (InterruptedException ie) {}





private static InitialContext getInitialContext(String url)

throws NamingException


Hashtable<String,String> env = new Hashtable<String,String>();


env.put(Context.PROVIDER_URL, url);

return new InitialContext(env);




Below image shows that the JMS QueueReceiver program is reading the WLDF notifications.

You can put your own business logic inside the QueueReceiver.java’s onMessage() method to specify the business requirements.

Do let us know, if you run into any issues configuring the same.  🙂

Best Regards

Latest Comments

  1. Shawn December 8, 2010
  2. anandraj December 9, 2010
  3. sid May 7, 2011
  4. Gaurav March 27, 2015

Leave a Reply