0 Replies Latest reply on Oct 4, 2005 3:30 AM by George Taylor

    Remote Notification Listener

    George Taylor Newbie

      I am trying to implement a remote notification listener. My MBean works ok, and i can access it remotely, but i want to add a listener to be notified on state changes.

      The code i have for the remote side is

      MBeanServerConnection settingsServer = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor");
      ObjectName sServer = new ObjectName("flytxt:service=settings");
      if (settingsServer.isRegistered(sServer)) {
       String server = InetAddress.getLocalHost().getHostName();
       settings = (Document) settingsServer.invoke(sServer, "getSettings",
       new Object[] { "ROOT/TRANSPORT/SERVER="+ server },
       new String[] { "java.lang.String" });
       ((RMIAdaptor)settingsServer).addNotificationListener(sServer, this,
       new AllNotificationFilter("ROOT/TRANSPORT/SERVER"), this);
      


      The MBean itself is an EJB3 MBean, here is a snippit of the code
      @Service(objectName = "flytxt:service=settings")
      public class Settings implements SettingsMBean , NotificationBroadcaster{
       private NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();
      
       public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
       throws IllegalArgumentException {
       broadcaster.addNotificationListener(listener, filter, handback);
       }
      
       public void removeNotificationListener(NotificationListener listener)
       throws ListenerNotFoundException {
       broadcaster.removeNotificationListener(listener);
       }
      
       public MBeanNotificationInfo[] getNotificationInfo() {
       return new MBeanNotificationInfo[] { new MBeanNotificationInfo(
       new String[] { "settings.server" }, Notification.class
       .getName(), "Settings Notification") };
       }
      
       public void broadcast() {
       broadcaster.sendNotification(new Notification("ROOT/TRANSPORT/SERVER", this,
       notificationSequence++, "settings updated"));
       broadcaster.sendNotification(new Notification("STOP", this,
       notificationSequence++, "settings updated"));
       }
      }
      


      when i run the code on the client side i get the following error

      08:25:10,189 INFO [STDOUT] javax.management.RuntimeOperationsException
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.addNotificationListener(MBeanServerImpl.java:724)
      08:25:10,189 INFO [STDOUT] at org.jboss.jmx.connector.invoker.InvokerAdaptorService.addNotificationListener(InvokerAdaptorService.java:288)
      08:25:10,189 INFO [STDOUT] at org.jboss.jmx.connector.invoker.InvokerAdaptorService.invoke(InvokerAdaptorService.java:236)
      08:25:10,189 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      08:25:10,189 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      08:25:10,189 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      08:25:10,189 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
      08:25:10,189 INFO [STDOUT] at org.jboss.jmx.connector.invoker.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:87)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      08:25:10,189 INFO [STDOUT] at org.jboss.invocation.jrmp.server.JRMPProxyFactory.invoke(JRMPProxyFactory.java:164)
      08:25:10,189 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      08:25:10,189 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      08:25:10,189 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      08:25:10,189 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
      08:25:10,189 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      08:25:10,204 INFO [STDOUT] at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
      08:25:10,204 INFO [STDOUT] at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
      08:25:10,204 INFO [STDOUT] at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:179)
      08:25:10,204 INFO [STDOUT] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:165)
      08:25:10,204 INFO [STDOUT] at org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor.invoke(InvokerAdaptorClientInterceptor.java:51)
      08:25:10,204 INFO [STDOUT] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
      08:25:10,204 INFO [STDOUT] at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:59)
      08:25:10,204 INFO [STDOUT] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
      08:25:10,204 INFO [STDOUT] at $Proxy98.addNotificationListener(Unknown Source)
      08:25:10,204 INFO [STDOUT] at com.flytxt.transport.jmx.TransportServer.loadSettings(TransportServer.java:426)
      08:25:10,204 INFO [STDOUT] at com.flytxt.transport.jmx.TransportServer.process(TransportServer.java:125)
      08:25:10,204 INFO [STDOUT] at com.flytxt.transport.jmx.TransportServer$WaitAndRun.run(TransportServer.java:103)
      08:25:10,204 INFO [STDOUT] Caused by: java.lang.IllegalArgumentException: The MBean named exists but does not implement the NotificationBroadcaster interface.
      


      I don't know if this is a bug or if i am doing something wrong, but it seems to me that the remote interface does not support the NotificationBroadcaster interface, so i tried having the MBean interface extend the NotificationBroadcaster interface, and that made no difference.

      If anyone can help me it would be much appreciated as at the moment i am having to write my own communications packages to send updates between the different servers, and as jboss already supports this, it would rather not have to.