[jboss-user] [Clustering] - Sending JMX notifications to all nodes in a cluster

himanshuIg do-not-reply at jboss.com
Fri Oct 9 09:51:03 EDT 2009


Hi All,

I am using JBoss 4.2.3 

I am trying to get JMX notifications working on a cluster. I have created two different classes
The class that sends a notification
import javax.management.*;
  | import org.jboss.ha.jmx.HAServiceMBean;
  | import org.jboss.ha.jmx.HAServiceMBeanSupport;
  | 
  | public class LayoutMBean
  |         extends HAServiceMBeanSupport implements HAServiceMBean {
  | 
  |     private long sequenceNumber = 1;
  | 
  |     private Layout layout;
  | 
  |     public void setLayout(Layout layout) {
  |         this.layout = layout;
  |     }
  | 
  |     public Layout getLayout() {
  |         return this.layout;
  |     }
  | 
  |     public void syncLayouts() throws Exception {
  |         System.out.println("Sending Notification");
  | 
  |         Notification n =
  |                 new Notification(
  |                         Layout.TYPE,
  |                         this,
  |                         sequenceNumber++,
  |                         System.currentTimeMillis(),
  |                         "All Layouts have been synced");
  |         sendNotification(n);
  |         System.out.println("Notification Sent.......");
  |     }
  | 
  | }

A NotificationListener
import javax.management.*;
  | 
  | public class LayoutNotificationListener implements NotificationListener {
  |     public void  handleNotification (Notification  notification, Object handback) {
  | 		System.out.println("Notifictaion Recieved...........");
  | 		System.out.println(notification.getMessage());
  |      }
  | 

I have a spring configuration to define object of both the NotificationSender and NotificationListener(layoutMBean and layoutNotificationListener respectively)

On Application start-up, I add a listener by the following code
LayoutMBean layoutMBean = ctx.getBean("layoutMBean")
  | LayoutNotifictionListener layoutNotifictionListener = ctx.getBean("layoutNotifictionListener")
  | layoutMBean.addNotificationListener(layoutNotifictionListener, null, null)
  | 

When I deploy this application on the cluster, notifications are not being received by other nodes in the cluster, i.e., just the node that generated the notification receives it
I expected that the notification send by one of the nodes will be received by all other listeners in the cluster. What am I missing here?

Thanks in advance

~~Himanshu Seth~~

http://www.IntelliGrape.com

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4259649#4259649

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4259649



More information about the jboss-user mailing list