Details
Description
I am using the JmxExporter class to expose QFJ to JMX. If I attempt to
shutdown and restart my QFJ instance (my stopping then restarting my
Initiator within the same process) then I get the following exception
because QFJ tries to export to JMX again.
... ... ERROR org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter -
Failed to export connector MBean
javax.management.InstanceAlreadyExistsException:
org.quickfixj:type=Session,beginString=FIX.4.2,xxxxxxxx
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1484)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:963)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:917)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482)
at
org.quickfixj.jmx.mbean.session.SessionJmxExporter.export(SessionJmxExporter.java:28)
at
org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter.export(ConnectorJmxExporter.java:66)
at
org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter.export(ConnectorJmxExporter.java:46)
at org.quickfixj.jmx.JmxExporter.export(JmxExporter.java:60)
Spring has a solution to this kind of thing with
MBeanRegistrationSupport.setRegistrationBehaviorName<http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/jmx/support/MBeanRegistrationSupport.html#setRegistrationBehaviorName%28java.lang.String%29>.