org.apache.activemq.artemis.rest.queue.DestinationSettings

Here are the examples of the java api class org.apache.activemq.artemis.rest.queue.DestinationSettings taken from open source projects.

1. MessageServiceManager#start()

View license
public void start() throws Exception {
    if (configuration == null || configSet == false) {
        if (configResourcePath == null) {
            configuration = new MessageServiceConfiguration();
        } else {
            URL url = getClass().getClassLoader().getResource(configResourcePath);
            if (url == null) {
                // The URL is outside of the classloader. Trying a pure url now
                url = new URL(configResourcePath);
            }
            JAXBContext jaxb = JAXBContext.newInstance(MessageServiceConfiguration.class);
            Reader reader = new InputStreamReader(url.openStream());
            String xml = XMLUtil.readerToString(reader);
            xml = XMLUtil.replaceSystemProps(xml);
            configuration = (MessageServiceConfiguration) jaxb.createUnmarshaller().unmarshal(new StringReader(xml));
        }
    }
    if (threadPool == null)
        threadPool = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory());
    timeoutTaskInterval = configuration.getTimeoutTaskInterval();
    timeoutTask = new TimeoutTask(timeoutTaskInterval);
    threadPool.execute(timeoutTask);
    DestinationSettings defaultSettings = new DestinationSettings();
    defaultSettings.setConsumerSessionTimeoutSeconds(configuration.getConsumerSessionTimeoutSeconds());
    defaultSettings.setDuplicatesAllowed(configuration.isDupsOk());
    defaultSettings.setDurableSend(configuration.isDefaultDurableSend());
    HashMap<String, Object> transportConfig = new HashMap<>();
    transportConfig.put(TransportConstants.SERVER_ID_PROP_NAME, configuration.getInVmId());
    ServerLocator consumerLocator = new ServerLocatorImpl(false, new TransportConfiguration(InVMConnectorFactory.class.getName(), transportConfig));
    ActiveMQRestLogger.LOGGER.debug("Created ServerLocator: " + consumerLocator);
    if (configuration.getConsumerWindowSize() != -1) {
        consumerLocator.setConsumerWindowSize(configuration.getConsumerWindowSize());
    }
    ClientSessionFactory consumerSessionFactory = consumerLocator.createSessionFactory();
    ActiveMQRestLogger.LOGGER.debug("Created ClientSessionFactory: " + consumerSessionFactory);
    ServerLocator defaultLocator = new ServerLocatorImpl(false, new TransportConfiguration(InVMConnectorFactory.class.getName(), transportConfig));
    ClientSessionFactory sessionFactory = defaultLocator.createSessionFactory();
    LinkStrategy linkStrategy = new LinkHeaderLinkStrategy();
    if (configuration.isUseLinkHeaders()) {
        linkStrategy = new LinkHeaderLinkStrategy();
    } else {
        linkStrategy = new CustomHeaderLinkStrategy();
    }
    queueManager.setServerLocator(defaultLocator);
    queueManager.setSessionFactory(sessionFactory);
    queueManager.setTimeoutTask(timeoutTask);
    queueManager.setConsumerServerLocator(consumerLocator);
    queueManager.setConsumerSessionFactory(consumerSessionFactory);
    queueManager.setDefaultSettings(defaultSettings);
    queueManager.setPushStoreFile(configuration.getQueuePushStoreDirectory());
    queueManager.setProducerPoolSize(configuration.getProducerSessionPoolSize());
    queueManager.setProducerTimeToLive(configuration.getProducerTimeToLive());
    queueManager.setLinkStrategy(linkStrategy);
    queueManager.setRegistry(registry);
    topicManager.setServerLocator(defaultLocator);
    topicManager.setSessionFactory(sessionFactory);
    topicManager.setTimeoutTask(timeoutTask);
    topicManager.setConsumerServerLocator(consumerLocator);
    topicManager.setConsumerSessionFactory(consumerSessionFactory);
    topicManager.setDefaultSettings(defaultSettings);
    topicManager.setPushStoreFile(configuration.getTopicPushStoreDirectory());
    topicManager.setProducerPoolSize(configuration.getProducerSessionPoolSize());
    queueManager.setProducerTimeToLive(configuration.getProducerTimeToLive());
    topicManager.setLinkStrategy(linkStrategy);
    topicManager.setRegistry(registry);
    queueManager.start();
    topicManager.start();
}