[QFJ-393] When using JmxExporter, restarting QFJ Initiator throws Exception re-registering mbean Created: 13/Jan/09  Updated: 11/Feb/09  Resolved: 20/Jan/09

Status: Closed
Project: QuickFIX/J
Component/s: Engine
Affects Version/s: 1.3.1, 1.3.3
Fix Version/s: 1.4.0

Type: Bug Priority: Default
Reporter: Jerry Shea Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Attachments: Text File jmxExporter.patch     Text File jmxExporter.patch    

 Description   

See http://sourceforge.net/mailarchive/forum.php?thread_name=ce06b7320901101754l6050baf0j888ae610bdd7bf04%40mail.gmail.com&forum_name=quickfixj-users

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>.



 Comments   
Comment by Jerry Shea [ 13/Jan/09 ]

Patch attached.
Instead of calling
mbeanServer.registerMBean(connectorAdmin, connectorName);
I have moved this functionality into JmxExporter class and added code (in fact very nearly a cut'n'paste of Spring's MBeanRegistrationSupport.doRegister method) to either blow up, ignore or re-register the mbean if there is one already there.

Patch was made against 1.3.3

Comment by Laurent Danesi [ 13/Jan/09 ]

Thank you Jerry.

I will apply you patch on trunk.

Laurent

Comment by Jerry Shea [ 13/Jan/09 ]

woops - fixed a mistake in the last patch

Generated at Mon Apr 29 16:51:36 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.