use of org.apache.activemq.artemis.rest.util.TimeoutTask in project activemq-artemis by apache.
the class MessageServiceManager method start.
public void start() throws Exception {
if (configuration == null || !configSet) {
if (configResourcePath == null) {
configuration = new MessageServiceConfiguration();
} else {
URL url = getClass().getClassLoader().getResource(configResourcePath);
if (isOutsideOfClassloader(url)) {
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());
ServerLocator consumerLocator = ActiveMQClient.createServerLocator(configuration.getUrl());
if (configuration.getConsumerWindowSize() != -1) {
consumerLocator.setConsumerWindowSize(configuration.getConsumerWindowSize());
}
ActiveMQRestLogger.LOGGER.debug("Created ServerLocator: " + consumerLocator);
consumerSessionFactory = consumerLocator.createSessionFactory();
ActiveMQRestLogger.LOGGER.debug("Created ClientSessionFactory: " + consumerSessionFactory);
ServerLocator defaultLocator = ActiveMQClient.createServerLocator(configuration.getUrl());
ClientSessionFactory sessionFactory = defaultLocator.createSessionFactory();
LinkStrategy linkStrategy;
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();
}
Aggregations