Uploaded image for project: 'QuickFIX/J'
  1. QuickFIX/J
  2. QFJ-182

JMX Connector object names are not unique

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Default
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: 1.2.0
    • Component/s: None
    • 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

        Attachments

          Activity

            People

            • Assignee:
              admin Steve Bate
              Reporter:
              thuegel Thomas Hügel
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: