Search in sources :

Example 1 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class JmsProviderLifecycle method eagerStartupRequired.

private boolean eagerStartupRequired() {
    JmsService jmsService = getJmsService();
    if (jmsService == null)
        return false;
    List<JmsHost> jmsHostList = jmsService.getJmsHost();
    if (jmsHostList == null)
        return false;
    String defaultJmsHostName = jmsService.getDefaultJmsHost();
    JmsHost defaultJmsHost = null;
    for (JmsHost host : jmsHostList) {
        if (defaultJmsHostName != null && defaultJmsHostName.equals(host.getName())) {
            defaultJmsHost = host;
            break;
        }
    }
    if (defaultJmsHost == null && jmsHostList.size() > 0) {
        defaultJmsHost = jmsHostList.get(0);
    }
    boolean lazyInit = false;
    if (defaultJmsHost != null)
        lazyInit = Boolean.parseBoolean(defaultJmsHost.getLazyInit());
    // we don't manage lifecycle of remote brokers
    if (brokerType == BROKER_TYPE.REMOTE)
        return false;
    // Initialize on demand is currently enabled based on a system property
    String jmsInitializeOnDemand = System.getProperty(JMS_INITIALIZE_ON_DEMAND);
    // if the system property is true, don't do eager startup
    if ("true".equals(jmsInitializeOnDemand))
        return false;
    if (brokerType == BROKER_TYPE.EMBEDDED && (!lazyInit))
        return true;
    // local broker has eager startup by default
    if (brokerType == BROKER_TYPE.LOCAL)
        return true;
    return false;
}
Also used : JmsService(com.sun.enterprise.connectors.jms.config.JmsService) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost)

Example 2 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class MQAddressList method getMasterBroker.

public String getMasterBroker(String clustername) {
    String masterbrk = null;
    // if (rep != null) {
    try {
        JmsHost mb = getMasterJmsHostInCluster(clustername);
        JmsService js = getJmsServiceForMasterBroker(clustername);
        MQUrl url = createUrl(mb, js);
        masterbrk = url.toString();
        if (logger.isLoggable(Level.FINE))
            logger.log(Level.FINE, "Master broker obtained is " + masterbrk);
    } catch (Exception e) {
        LogHelper.log(logger, Level.SEVERE, JMSLoggerInfo.GET_MASTER_FAILED, e);
    }
    // }
    return masterbrk;
}
Also used : JmsService(com.sun.enterprise.connectors.jms.config.JmsService) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost) IOException(java.io.IOException) PropertyVetoException(java.beans.PropertyVetoException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 3 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class ListJMSHosts method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    Config targetConfig = domain.getConfigNamed(target);
    if (targetConfig != null)
        config = targetConfig;
    Server targetServer = domain.getServerNamed(target);
    // String configRef = targetServer.getConfigRef();
    if (targetServer != null) {
        config = domain.getConfigNamed(targetServer.getConfigRef());
    }
    com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
    if (cluster != null) {
        config = domain.getConfigNamed(cluster.getConfigRef());
    }
    JmsService jmsService = config.getExtensionByType(JmsService.class);
    if (jmsService == null) {
        report.setMessage(localStrings.getLocalString("list.jms.host.invalidTarget", "Invalid Target specified."));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        ArrayList<String> list = new ArrayList();
        for (JmsHost r : jmsService.getJmsHost()) {
            list.add(r.getName());
        }
        for (String jmsName : list) {
            final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
            part.setMessage(jmsName);
        }
    } catch (Exception e) {
        report.setMessage(localStrings.getLocalString("list.jms.host.fail", "Unable to list JMS Hosts") + " " + e.getLocalizedMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
        return;
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : JmsService(com.sun.enterprise.connectors.jms.config.JmsService) ArrayList(java.util.ArrayList) ActionReport(org.glassfish.api.ActionReport) com.sun.enterprise.config.serverbeans(com.sun.enterprise.config.serverbeans) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost)

Example 4 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class ActiveJmsResourceAdapter method loadRAConfiguration.

/**
 * Loads RA configuration for MQ Resource adapter.
 *
 * @throws ConnectorRuntimeException in case of an exception.
 */
@Override
protected void loadRAConfiguration() throws ConnectorRuntimeException {
    JmsService jmsService = getJmsService();
    if (jmsService != null && jmsService.getType().equals("DISABLED")) {
        throw new ConnectorRuntimeException("JMS Broker is Disabled");
    }
    if (connectorRuntime.isServer()) {
        // Check whether MQ has started up or not.
        try {
            // if (!JmsProviderLifecycle.shouldUseMQRAForLifecycleControl()) {
            // JmsProviderLifecycle.checkProviderStartup();
            // } else {
            setLifecycleProperties();
        // }
        } catch (Exception e) {
            ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
            throw (ConnectorRuntimeException) cre.initCause(e);
        }
        setMdbContainerProperties();
        setJmsServiceProperties(null);
        setClusterRABeanProperties();
        setAvailabilityProperties();
    } else {
        setAppClientRABeanProperties();
    }
    super.loadRAConfiguration();
    postRAConfiguration();
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) MultiException(org.glassfish.hk2.api.MultiException) PrivilegedActionException(java.security.PrivilegedActionException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 5 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class ActiveJmsResourceAdapter method destroy.

@Override
public void destroy() {
    try {
        JmsService jmsService = getJmsService();
        if (jmsService != null && jmsService.getType().equals("DISABLED")) {
            return;
        }
        if (connectorRuntime.isServer() && grizzlyListenerInit && jmsService != null && EMBEDDED.equalsIgnoreCase(jmsService.getType())) {
            GrizzlyService grizzlyService = null;
            try {
                grizzlyService = Globals.get(GrizzlyService.class);
            } catch (MultiException rle) {
            // if GrizzlyService was shut down already, skip removing the proxy.
            }
            if (grizzlyService != null) {
                synchronized (grizzlyListeners) {
                    if (grizzlyListeners.size() > 0) {
                        String[] listeners = grizzlyListeners.toArray(new String[grizzlyListeners.size()]);
                        for (String listenerName : listeners) {
                            try {
                                grizzlyService.removeNetworkProxy(listenerName);
                                grizzlyListeners.remove(listenerName);
                            } catch (Exception e) {
                                LogHelper.log(_logger, Level.WARNING, JMSLoggerInfo.SHUTDOWN_FAIL_GRIZZLY, e, listenerName);
                            }
                        }
                    }
                }
            }
            grizzlyListenerInit = false;
        }
    } catch (Throwable th) {
        if (_logger.isLoggable(Level.WARNING)) {
            _logger.log(Level.WARNING, JMSLoggerInfo.SHUTDOWN_FAIL_JMSRA, new Object[] { th.getMessage() });
        }
        throw new RuntimeException(th);
    }
    super.destroy();
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) GrizzlyService(com.sun.enterprise.v3.services.impl.GrizzlyService) MultiException(org.glassfish.hk2.api.MultiException) MultiException(org.glassfish.hk2.api.MultiException) PrivilegedActionException(java.security.PrivilegedActionException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Aggregations

JmsService (com.sun.enterprise.connectors.jms.config.JmsService)22 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)10 JmsHost (com.sun.enterprise.connectors.jms.config.JmsHost)10 PrivilegedActionException (java.security.PrivilegedActionException)6 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)6 ActionReport (org.glassfish.api.ActionReport)6 PropertyVetoException (java.beans.PropertyVetoException)5 URISyntaxException (java.net.URISyntaxException)5 ExecutionException (java.util.concurrent.ExecutionException)5 MultiException (org.glassfish.hk2.api.MultiException)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)4 com.sun.enterprise.config.serverbeans (com.sun.enterprise.config.serverbeans)3 Cluster (com.sun.enterprise.config.serverbeans.Cluster)3 Server (com.sun.enterprise.config.serverbeans.Server)3 ServerContext (org.glassfish.internal.api.ServerContext)3 Domain (com.sun.enterprise.config.serverbeans.Domain)2 JmsAvailability (com.sun.enterprise.connectors.jms.config.JmsAvailability)2 ActiveJmsResourceAdapter (com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter)2 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)2 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)2