Search in sources :

Example 1 with MdbContainer

use of org.glassfish.ejb.config.MdbContainer in project Payara by payara.

the class MessageBeanContainer method createMessageBeanPool.

private void createMessageBeanPool(EjbMessageBeanDescriptor descriptor) {
    beanPoolDesc_ = descriptor.getIASEjbExtraDescriptors().getBeanPool();
    if (beanPoolDesc_ == null) {
        beanPoolDesc_ = new BeanPoolDescriptor();
    }
    MdbContainer mdbc = ejbContainerUtilImpl.getServices().<Config>getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME).getExtensionByType(MdbContainer.class);
    int maxPoolSize = beanPoolDesc_.getMaxPoolSize();
    if (maxPoolSize < 0) {
        maxPoolSize = stringToInt(mdbc.getMaxPoolSize(), appEJBName_, _logger);
    }
    maxPoolSize = validateValue(maxPoolSize, 1, -1, DEFAULT_MAX_POOL_SIZE, "max-pool-size", appEJBName_, _logger);
    beanPoolDesc_.setMaxPoolSize(maxPoolSize);
    int value = beanPoolDesc_.getSteadyPoolSize();
    if (value < 0) {
        value = stringToInt(mdbc.getSteadyPoolSize(), appEJBName_, _logger);
    }
    value = validateValue(value, 0, maxPoolSize, DEFAULT_STEADY_SIZE, "steady-pool-size", appEJBName_, _logger);
    beanPoolDesc_.setSteadyPoolSize(value);
    value = beanPoolDesc_.getPoolResizeQuantity();
    if (value < 0) {
        value = stringToInt(mdbc.getPoolResizeQuantity(), appEJBName_, _logger);
    }
    value = validateValue(value, 1, maxPoolSize, DEFAULT_RESIZE_QUANTITY, "pool-resize-quantity", appEJBName_, _logger);
    beanPoolDesc_.setPoolResizeQuantity(value);
    // if ejb pool idle-timeout-in-seconds is not explicitly set in
    // glassfish-ejb-jar.xml, returned value is -1
    value = beanPoolDesc_.getPoolIdleTimeoutInSeconds();
    if (value < MIN_IDLE_TIMEOUT) {
        value = stringToInt(mdbc.getIdleTimeoutInSeconds(), appEJBName_, _logger);
    }
    value = validateValue(value, MIN_IDLE_TIMEOUT, -1, DEFAULT_IDLE_TIMEOUT, "idle-timeout-in-seconds", appEJBName_, _logger);
    beanPoolDesc_.setPoolIdleTimeoutInSeconds(value);
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, appEJBName_ + ": Setting message-driven bean pool max-pool-size=" + beanPoolDesc_.getMaxPoolSize() + ", steady-pool-size=" + beanPoolDesc_.getSteadyPoolSize() + ", pool-resize-quantity=" + beanPoolDesc_.getPoolResizeQuantity() + ", idle-timeout-in-seconds=" + beanPoolDesc_.getPoolIdleTimeoutInSeconds());
    }
    // Create a non-blocking pool of message bean instances.
    // The protocol manager implementation enforces a limit
    // on message bean resources independent of the pool.
    ObjectFactory objFactory = new MessageBeanContextFactory();
    String val = descriptor.getEjbBundleDescriptor().getEnterpriseBeansProperty(SINGLETON_BEAN_POOL_PROP);
    messageBeanPool_ = new NonBlockingPool(getContainerId(), appEJBName_, objFactory, beanPoolDesc_.getSteadyPoolSize(), beanPoolDesc_.getPoolResizeQuantity(), beanPoolDesc_.getMaxPoolSize(), beanPoolDesc_.getPoolIdleTimeoutInSeconds(), loader, Boolean.parseBoolean(val));
}
Also used : MdbContainer(org.glassfish.ejb.config.MdbContainer) ObjectFactory(com.sun.ejb.containers.util.pool.ObjectFactory) NonBlockingPool(com.sun.ejb.containers.util.pool.NonBlockingPool) Config(com.sun.enterprise.config.serverbeans.Config) BeanPoolDescriptor(com.sun.enterprise.deployment.runtime.BeanPoolDescriptor) MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint)

Example 2 with MdbContainer

use of org.glassfish.ejb.config.MdbContainer in project Payara by payara.

the class JmsRaUtil method setMdbContainerProperties.

public void setMdbContainerProperties() {
    MdbContainer mdbc = null;
    try {
        mdbc = Globals.get(MdbContainer.class);
    } catch (Exception e) {
        _logger.log(Level.WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, new Object[] { e.getMessage() });
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, e.getClass().getName(), e);
        }
    }
    if (mdbc != null) {
        // getElementProperty();
        List props = mdbc.getProperty();
        if (props != null) {
            for (int i = 0; i < props.size(); i++) {
                Property p = (Property) props.get(i);
                if (p == null)
                    continue;
                String name = p.getName();
                if (name == null)
                    continue;
                try {
                    if (name.equals(propName_reconnect_enabled)) {
                        if (p.getValue() == null)
                            continue;
                        reconnectEnabled = Boolean.valueOf(p.getValue()).booleanValue();
                    } else if (name.equals(propName_reconnect_delay_in_seconds)) {
                        try {
                            reconnectDelayInSeconds = Integer.parseInt(p.getValue());
                        } catch (Exception e) {
                            _logger.log(Level.WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, new Object[] { e.getMessage() });
                        }
                    } else if (name.equals(propName_reconnect_max_retries)) {
                        try {
                            reconnectMaxRetries = Integer.parseInt(p.getValue());
                        } catch (Exception e) {
                            _logger.log(Level.WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, new Object[] { e.getMessage() });
                        }
                    } else if (name.equals(propName_cmt_max_runtime_exceptions)) {
                        try {
                            cmtMaxRuntimeExceptions = Integer.parseInt(p.getValue());
                        } catch (Exception e) {
                            _logger.log(Level.WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, new Object[] { e.getMessage() });
                        }
                    }
                } catch (Exception e) {
                    _logger.log(Level.WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, new Object[] { e.getMessage() });
                    if (_logger.isLoggable(Level.FINE)) {
                        _logger.log(Level.FINE, e.getClass().getName(), e);
                    }
                }
            }
        }
    }
    if (reconnectDelayInSeconds < 0) {
        reconnectDelayInSeconds = DEFAULT_RECONNECT_DELAY;
    }
    if (reconnectMaxRetries < 0) {
        reconnectMaxRetries = DEFAULT_RECONNECT_RETRIES;
    }
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, propName_reconnect_delay_in_seconds + "=" + reconnectDelayInSeconds + ", " + propName_reconnect_max_retries + "=" + reconnectMaxRetries + ", " + propName_reconnect_enabled + "=" + reconnectEnabled);
    }
    // Now set all these properties in the active resource adapter
    MdbContainerProps.setReconnectDelay(reconnectDelayInSeconds);
    MdbContainerProps.setReconnectMaxRetries(reconnectMaxRetries);
    MdbContainerProps.setReconnectEnabled(reconnectEnabled);
    MdbContainerProps.setMaxRuntimeExceptions(cmtMaxRuntimeExceptions);
}
Also used : MdbContainer(org.glassfish.ejb.config.MdbContainer) MQAddressList(com.sun.enterprise.connectors.jms.system.MQAddressList) List(java.util.List) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) Property(org.jvnet.hk2.config.types.Property) ZipFileException(com.sun.enterprise.util.zip.ZipFileException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Aggregations

MdbContainer (org.glassfish.ejb.config.MdbContainer)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 NonBlockingPool (com.sun.ejb.containers.util.pool.NonBlockingPool)1 ObjectFactory (com.sun.ejb.containers.util.pool.ObjectFactory)1 Config (com.sun.enterprise.config.serverbeans.Config)1 MQAddressList (com.sun.enterprise.connectors.jms.system.MQAddressList)1 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)1 BeanPoolDescriptor (com.sun.enterprise.deployment.runtime.BeanPoolDescriptor)1 ZipFileException (com.sun.enterprise.util.zip.ZipFileException)1 List (java.util.List)1 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)1 Property (org.jvnet.hk2.config.types.Property)1