[QFJ-182] JMX Connector object names are not unique Created: 22/May/07  Updated: 04/Jul/07  Resolved: 25/May/07

Status: Closed
Project: QuickFIX/J
Component/s: None
Affects Version/s: 1.1.0
Fix Version/s: 1.2.0

Type: Bug Priority: Default
Reporter: Thomas Hügel Assignee: Steve Bate
Resolution: Fixed Votes: 0
Labels: None


 Description   

Hello,

the current implementation of ConnectorJMXExporter.java does only work if you dont use a second connector. The name "type=Connector,role=Initiator" is to generic because the second connector has allways the same name, the error would look like the following:

22.05.2007 17:49:24 org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter export
SCHWERWIEGEND: Failed to export connector MBean
javax.management.InstanceAlreadyExistsException: org.quickfixj:type=Connector,role=Initiator
at com.sun.jmx.mbeanserver.RepositorySupport.addMBean(RepositorySupport.java:452)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1410)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:936)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:337)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:497)
at org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter.export(ConnectorJmxExporter.java:56)
at org.quickfixj.jmx.JmxExporter.export(JmxExporter.java:60)

My approach was to add the name of the configFile in the JMXExporter.export() function, this is probably to simple in case that the configfiles are not in the same directory. Must be a better way.

****
public void export(MBeanServer mbeanServer, SessionConnector connector, String configFileName) {
try {
ConnectorAdmin connectorAdmin;
if (connector instanceof AbstractSocketAcceptor)

{ connectorAdmin = new SocketAcceptorAdmin((AbstractSocketAcceptor) connector, sessionExporter); }

else if (connector instanceof AbstractSocketInitiator)

{ connectorAdmin = new SocketInitiatorAdmin((AbstractSocketInitiator) connector, sessionExporter); }

else

{ throw new QFJException("Unknown connector type: " + connector.getClass().getName()); }

//changed: ObjectName connectorName = getConnectorName(connector);
ObjectName connectorName = getConnectorName(connector, configFileName);

mbeanServer.registerMBean(connectorAdmin, connectorName);
ArrayList sessionIDs = connector.getSessions();
for (int i = 0; i < sessionIDs.size(); i++)

{ SessionID sessionID = (SessionID) sessionIDs.get(i); sessionExporter.export(mbeanServer, Session.lookupSession(sessionID), connectorName, connector.getSettings()); }

} catch (Exception e)

{ log.error("Failed to export connector MBean", e); }

}
//private ObjectName getConnectorName(SessionConnector connector)
private ObjectName getConnectorName(SessionConnector connector, String configFileName)
throws MalformedObjectNameException

{ ObjectNameFactory nameFactory = new ObjectNameFactory(); nameFactory.addProperty("type", "Connector"); nameFactory.addProperty("role", connector instanceof Acceptor ? "Acceptor" : "Initiator"); //changed nameFactory.addProperty("configFileName", configFileName); return nameFactory.createName(); }

***

The jmx export im my code looks like

jmxExporter = new JmxExporter(ManagementFactory.getPlatformMBeanServer());
jmxExporter.export(acceptor, this.getConfigFile());

instead of

jmxExporter = new JmxExporter(ManagementFactory.getPlatformMBeanServer());
jmxExporter.export(acceptor);

I checked with jconsole, works.

Regards
Thomas Hügel


Generated at Sat Nov 23 07:31:30 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.