public void unregister(URI uri) throws JMSException { AdaptiveMessageContainer container = containers.remove(uri); if (container != null) { container.shutdown(); try { String encodedName = encodeName(uri); String encodedGroup = encodeGroup(uri); managementService.remove(encodedName, encodedGroup); } catch (ManagementException e) { throw new JMSException(e.getMessage()); } managerMonitor.unRegisterListener(uri); } }
public void register(ContainerConfiguration configuration) throws JMSException { URI uri = configuration.getUri(); if (containers.containsKey(uri)) { throw new JMSException("Container already registered: " + uri); } ConnectionFactory factory = configuration.getFactory(); TransactionType type = configuration.getType(); String clientId = configuration.getClientId(); boolean durable = configuration.isDurable(); int cacheLevel = configuration.getCacheLevel(); boolean cacheConnection = cacheLevel >= CACHE_CONNECTION; // set the receive timeout to half of the trx timeout int receiveTimeout = transactionTimeout / 2; ContainerStatistics statistics = new ContainerStatistics(); ConnectionManager connectionManager = new ConnectionManager(factory, uri, clientId, cacheConnection, durable, containerMonitor); UnitOfWork transactionHelper = new UnitOfWork(uri, type, transactionTimeout, tm, statistics); AdaptiveMessageContainer container = new AdaptiveMessageContainer( configuration, receiveTimeout, connectionManager, transactionHelper, statistics, executorService, containerMonitor); containers.put(uri, container); try { String encodedName = encodeName(uri); String encodedGroup = encodeGroup(uri); managementService.export(encodedName, encodedGroup, "JMS message container", container); } catch (ManagementException e) { throw new JMSException(e.getMessage()); } if (started) { container.initialize(); managerMonitor.registerListener(uri); } }