use of org.apache.activemq.artemis.rest.queue.DestinationSettings in project activemq-artemis by apache.
the class TopicDestinationsResource method findTopic.
@Path("/{topic-name}")
public TopicResource findTopic(@PathParam("topic-name") String name) throws Exception {
TopicResource topic = topics.get(name);
if (topic == null) {
ClientSession session = manager.getSessionFactory().createSession(false, false, false);
try {
ClientSession.AddressQuery query = session.addressQuery(new SimpleString(name));
if (!query.isExists()) {
System.err.println("Topic '" + name + "' does not exist");
throw new WebApplicationException(Response.status(404).type("text/plain").entity("Topic '" + name + "' does not exist").build());
}
DestinationSettings queueSettings = manager.getDefaultSettings();
boolean defaultDurable = queueSettings.isDurableSend();
topic = createTopicResource(name, defaultDurable, queueSettings.getConsumerSessionTimeoutSeconds(), queueSettings.isDuplicatesAllowed());
} finally {
try {
session.close();
} catch (ActiveMQException e) {
}
}
}
return topic;
}
use of org.apache.activemq.artemis.rest.queue.DestinationSettings 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