Search in sources :

Example 1 with JmxExporter

use of org.quickfixj.jmx.JmxExporter in project wso2-synapse by wso2.

the class FIXSessionFactory method initJMX.

private void initJMX(Connector connector, String service) {
    try {
        JmxExporter jmxExporter = new JmxExporter();
        jmxExporter.setRegistrationBehavior(JmxExporter.REGISTRATION_IGNORE_EXISTING);
        jmxExporter.export(connector);
    } catch (JMException e) {
        log.error("Error while initializing JMX support for the service: " + service, e);
    }
}
Also used : JmxExporter(org.quickfixj.jmx.JmxExporter) JMException(javax.management.JMException)

Example 2 with JmxExporter

use of org.quickfixj.jmx.JmxExporter in project camel by apache.

the class QuickfixjEngine method initializeEngine.

/**
     * Initializes the engine on demand. May be called immediately in constructor or when needed.
     * If initializing later, it should be started afterwards.
     */
void initializeEngine() throws ConfigError, FieldConvertError, JMException {
    if (messageFactory == null) {
        messageFactory = new DefaultMessageFactory();
    }
    if (sessionLogFactory == null) {
        sessionLogFactory = inferLogFactory(settings);
    }
    if (messageStoreFactory == null) {
        messageStoreFactory = inferMessageStoreFactory(settings);
    }
    // Set default session schedule if not specified in configuration
    if (!settings.isSetting(Session.SETTING_START_TIME)) {
        settings.setString(Session.SETTING_START_TIME, DEFAULT_START_TIME);
    }
    if (!settings.isSetting(Session.SETTING_END_TIME)) {
        settings.setString(Session.SETTING_END_TIME, DEFAULT_END_TIME);
    }
    // Default heartbeat interval
    if (!settings.isSetting(Session.SETTING_HEARTBTINT)) {
        settings.setLong(Session.SETTING_HEARTBTINT, DEFAULT_HEARTBTINT);
    }
    // Allow specification of the QFJ threading model
    ThreadModel threadModel = ThreadModel.ThreadPerConnector;
    if (settings.isSetting(SETTING_THREAD_MODEL)) {
        threadModel = ThreadModel.valueOf(settings.getString(SETTING_THREAD_MODEL));
    }
    if (settings.isSetting(SETTING_USE_JMX) && settings.getBool(SETTING_USE_JMX)) {
        LOG.info("Enabling JMX for QuickFIX/J");
        jmxExporter = new JmxExporter();
    } else {
        jmxExporter = null;
    }
    // From original component implementation...
    // To avoid this exception in OSGi platform
    // java.lang.NoClassDefFoundError: quickfix/fix41/MessageFactory
    ClassLoader ccl = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
        if (isConnectorRole(settings, SessionFactory.ACCEPTOR_CONNECTION_TYPE)) {
            acceptor = createAcceptor(new Dispatcher(), settings, messageStoreFactory, sessionLogFactory, messageFactory, threadModel);
        } else {
            acceptor = null;
        }
        if (isConnectorRole(settings, SessionFactory.INITIATOR_CONNECTION_TYPE)) {
            initiator = createInitiator(new Dispatcher(), settings, messageStoreFactory, sessionLogFactory, messageFactory, threadModel);
        } else {
            initiator = null;
        }
        if (acceptor == null && initiator == null) {
            throw new ConfigError("No connector role");
        }
    } finally {
        Thread.currentThread().setContextClassLoader(ccl);
    }
    initialized.set(true);
}
Also used : DefaultMessageFactory(quickfix.DefaultMessageFactory) ConfigError(quickfix.ConfigError) JmxExporter(org.quickfixj.jmx.JmxExporter)

Aggregations

JmxExporter (org.quickfixj.jmx.JmxExporter)2 JMException (javax.management.JMException)1 ConfigError (quickfix.ConfigError)1 DefaultMessageFactory (quickfix.DefaultMessageFactory)1