Search in sources :

Example 1 with ResourceAdapterInternalException

use of jakarta.resource.spi.ResourceAdapterInternalException in project openmq by eclipse-ee4j.

the class LifecycleManagedBroker method start.

/**
 * Starts the lifecycle managed broker.
 */
public synchronized void start() throws ResourceAdapterInternalException {
    if (BROKER_TYPE_LOCAL.equals(brokerType)) {
        try {
            lbr = new LocalBrokerRunner(getBrokerUrl(), brokerInstanceName, brokerBindAddress, brokerPort, brokerHomeDir, brokerLibDir, brokerVarDir, brokerJavaDir, brokerArgs, useJNDIRmiServiceURL, rmiRegistryPort, startRmiRegistry, useSSLJMXConnector, brokerStartTimeout, adminUsername, adminPassFile, new EffectiveBrokerProps());
            lbr.start();
        } catch (Exception lbse) {
            ResourceAdapterInternalException raie = new ResourceAdapterInternalException(_lgrMID_EXC + "start:Aborting:Exception starting LOCAL broker=" + lbse.getMessage());
            raie.initCause(lbse);
            _loggerL.severe(raie.getMessage());
            _loggerL.info(this.toString());
            lbse.printStackTrace();
            _loggerL.throwing(_className, "start()", raie);
            throw raie;
        }
    } else {
        if (isInProcess()) {
            try {
                if (!_startedAtLeastOnce) {
                    _rmiRegistryPort = rmiRegistryPort;
                }
                if (ebr == null) {
                    ebr = new EmbeddedBrokerRunner(brokerInstanceName, brokerBindAddress, brokerPort, brokerHomeDir, brokerLibDir, brokerVarDir, brokerJavaDir, brokerArgs, useJNDIRmiServiceURL, _rmiRegistryPort, startRmiRegistry, useSSLJMXConnector, doBind, _getEffectiveBrokerProps());
                    ebr.init();
                }
                ebr.start();
                _setRAJMSService(ebr.getJMSService());
                _startedAtLeastOnce = true;
            } catch (Exception ebse) {
                ResourceAdapterInternalException raie = new ResourceAdapterInternalException(_lgrMID_EXC + "start:Aborting:Exception starting EMBEDDED broker=" + ebse.getMessage());
                raie.initCause(ebse);
                _loggerL.severe(raie.getMessage());
                _loggerL.info(this.toString());
                ebse.printStackTrace();
                _loggerL.throwing(_className, "start()", raie);
                throw raie;
            }
        }
    }
    started = true;
}
Also used : ResourceAdapterInternalException(jakarta.resource.spi.ResourceAdapterInternalException) ResourceAdapterInternalException(jakarta.resource.spi.ResourceAdapterInternalException) JMSException(jakarta.jms.JMSException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 2 with ResourceAdapterInternalException

use of jakarta.resource.spi.ResourceAdapterInternalException in project openmq by eclipse-ee4j.

the class ResourceAdapter method start.

// ResourceAdapter interface methods //
// 
/**
 * <p>
 * Starts this instance of the Resource Adapter. <br>
 * <p>
 * If this resource adapter is configured to perform broker lifecycle management
 * (i.e.<tt>setManageBrokerLifecycle(false)</tt> has not been called) and the configured broker type is not
 * <tt>REMOTE</tt>, then this also starts the managed broker.
 */
@Override
public synchronized void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
    _loggerL.entering(_className, "start()", ctx);
    JMSRAResourceAdapter.init();
    if (started) {
        _loggerL.warning(_lgrMID_WRN + "start:Previously started:Ignoring");
    } else {
        fixBrokerType();
        Version version = new Version();
        _loggerL.info(_lgrMID_INF + "GlassFish MQ JMS Resource Adapter: " + version.getRAVersion());
        _loggerL.info(_lgrMID_INF + "GlassFish MQ JMS Resource Adapter starting: broker is " + getPublicBrokerType() + ", connection mode is " + getPublicConnectionType());
        this.b_context = ctx;
        if (b_context != null) {
            workMgr = b_context.getWorkManager();
        }
        // Try to set inAppClientContainer correctly
        _adjustInAppClientContainer();
        this.xacf = new com.sun.messaging.XAConnectionFactory();
        AccessController.doPrivileged(new PrivilegedAction<Object>() {

            @Override
            public Object run() {
                System.setProperty("imq.DaemonThreads", "true");
                return null;
            }
        });
        // if we have been configured to start a managed broker, start it
        if (isManageBrokerLifecycle() && !this._isRemote()) {
            getLifecycleManagedBroker().start();
        }
        try {
            // Configure RA ConnectionFactory
            // will throw a JMSException if the properties are invalid
            configureFactory();
        } catch (JMSException jmse) {
            // If we have just started a local broker then stop it
            if (getLifecycleManagedBroker().isStarted() && getLifecycleManagedBroker().isLocal()) {
                getLifecycleManagedBroker().stop();
            }
            ResourceAdapterInternalException raie = new ResourceAdapterInternalException(_lgrMID_EXC + "start:Aborting:JMSException on createConnection=" + jmse.getMessage());
            raie.initCause(jmse);
            _loggerL.severe(raie.getMessage());
            jmse.printStackTrace();
            _loggerL.throwing(_className, "start()", raie);
            throw raie;
        }
        /* init hash maps */
        epFactories = new HashMap<>(10);
        epConsumers = new HashMap<>(10);
        epFactoryToConsumer = new HashMap<>(10);
        _setOnMessageMethod();
        started = true;
        _loggerL.config(_lgrMID_INF + toString());
        _loggerL.config(_lgrMID_INF + "start:SJSMQ JMSRA Connection Factory Config=" + xacf.getCurrentConfiguration());
        _loggerL.info(_lgrMID_INF + "GlassFish MQ JMS Resource Adapter Started:" + getPublicBrokerType());
    }
    _loggerL.exiting(_className, "start()");
}
Also used : Version(com.sun.messaging.jmq.Version) JMSException(jakarta.jms.JMSException) ResourceAdapterInternalException(jakarta.resource.spi.ResourceAdapterInternalException)

Aggregations

JMSException (jakarta.jms.JMSException)2 ResourceAdapterInternalException (jakarta.resource.spi.ResourceAdapterInternalException)2 Version (com.sun.messaging.jmq.Version)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1