We have written the following code:
and in jconsole
We have clicked on Subscribe in the Notifications tab on the left, but we don't see any notifications. Please suggest.
Code:jmxApplication.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"/> <!-- this bean must not be lazily initialized if the exporting is to happen --> <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false"> <property name="beans"> <map> <entry key="bean:name=testBean1" value-ref="testBean"/> </map> </property> <property name="server" ref="mbeanServer"/> <property name="autodetect" value="true"/> <property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/> <property name="notificationListenerMappings"> <map> <entry key="bean:name=testBean1"> <bean class="org.springframework.jmx.ConsoleLoggingNotificationListener"/> </entry> </map> </property> </bean> <bean id="listener" class="org.springframework.jmx.ConsoleLoggingNotificationListener"/> <bean id="testBean" class="org.springframework.jmx.JmxTestBean"> <property name="name" value="TEST"/> <property name="age" value="100"/> </bean> <bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean" lazy-init="false"> <property name="objectName" value="connector:name=rmi"/> <property name="serviceUrl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/myconnector"/> <property name="threaded" value="true"/> <property name="daemon" value="true"/> <property name="server"> <ref local="mbeanServer"/> </property> </bean> <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"> <property name="port" value="1099"/> </bean> </beans> <<MainClass.java>> package org.springframework.jmx; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; public class MainClass { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("jmxApplication.xml", MainClass.class); System.out.println("Waiting for clients..."); } } <<ConsoleLoggingNotificationListener.java>> package org.springframework.jmx; import javax.management.AttributeChangeNotification; import javax.management.Notification; import javax.management.NotificationFilter; import javax.management.NotificationListener; public class ConsoleLoggingNotificationListener implements NotificationListener, NotificationFilter { /** * */ private static final long serialVersionUID = 1482087826069816805L; @Override public void handleNotification(Notification notification, Object handback) { System.out.println(notification); System.out.println(handback); } public boolean isNotificationEnabled(Notification notification) { return AttributeChangeNotification.class.isAssignableFrom(notification.getClass()); } } We started the jconsole using jconsole service:jmx:rmi://localhost/jndi/rmi://localhost:1099/myconnector


Reply With Quote
