use of org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration in project activemq-artemis by apache.
the class FileBroker method start.
@Override
public synchronized void start() throws Exception {
if (started) {
return;
}
// todo if we start to pullout more configs from the main config then we should pull out the configuration objects from factories if available
FileConfiguration configuration = new FileConfiguration();
// Keep this as we still want to parse destinations in the <jms> element
FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration();
FileDeploymentManager fileDeploymentManager = new FileDeploymentManager(configurationUrl);
fileDeploymentManager.addDeployable(configuration).addDeployable(jmsConfiguration);
fileDeploymentManager.readConfiguration();
createDirectories(configuration);
/**
* This is a bit of a hack for backwards config compatibility since we no longer want to start the broker
* using the JMSServerManager which would normally deploy JMS destinations. Here we take the JMS destination
* configurations from the parsed JMS configuration and add them to the core configuration.
*
* It's also important here that we are adding them to the core ADDRESS configurations as those will be
* deployed first and therefore their configuration will take precedence over other legacy queue configurations
* which are deployed later. This is so we can maintain support for configurations like those found in the
* bridge and divert examples where there are JMS and core queues with the same name (which was itself a bit
* of a hack).
*
* This should be removed when support for the old "jms" configuation element is also removed.
*/
{
for (JMSQueueConfiguration jmsQueueConfig : jmsConfiguration.getQueueConfigurations()) {
List<CoreAddressConfiguration> coreAddressConfigurations = configuration.getAddressConfigurations();
coreAddressConfigurations.add(new CoreAddressConfiguration().setName(jmsQueueConfig.getName()).addRoutingType(RoutingType.ANYCAST).addQueueConfiguration(new CoreQueueConfiguration().setAddress(jmsQueueConfig.getName()).setName(jmsQueueConfig.getName()).setFilterString(jmsQueueConfig.getSelector()).setRoutingType(RoutingType.ANYCAST)));
}
for (TopicConfiguration topicConfig : jmsConfiguration.getTopicConfigurations()) {
List<CoreAddressConfiguration> coreAddressConfigurations = configuration.getAddressConfigurations();
coreAddressConfigurations.add(new CoreAddressConfiguration().setName(topicConfig.getName()).addRoutingType(RoutingType.MULTICAST));
}
}
components = fileDeploymentManager.buildService(securityManager, ManagementFactory.getPlatformMBeanServer());
ArrayList<ActiveMQComponent> componentsByStartOrder = getComponentsByStartOrder(components);
ActiveMQBootstrapLogger.LOGGER.serverStarting();
for (ActiveMQComponent component : componentsByStartOrder) {
component.start();
}
started = true;
}
use of org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration in project activemq-artemis by apache.
the class QueueDestinationsResource method createJmsQueue.
@POST
@Consumes("application/activemq.jms.queue+xml")
public Response createJmsQueue(@Context UriInfo uriInfo, Document document) {
ActiveMQRestLogger.LOGGER.debug("Handling POST request for \"" + uriInfo.getPath() + "\"");
try {
JMSQueueConfiguration queue = FileJMSConfiguration.parseQueueConfiguration(document.getDocumentElement());
ActiveMQQueue activeMQQueue = ActiveMQDestination.createQueue(queue.getName());
String queueName = activeMQQueue.getAddress();
ClientSession session = manager.getSessionFactory().createSession(false, false, false);
try {
ClientSession.QueueQuery query = session.queueQuery(new SimpleString(queueName));
if (!query.isExists()) {
if (queue.getSelector() != null) {
session.createQueue(queueName, queueName, queue.getSelector(), queue.isDurable());
} else {
session.createQueue(queueName, queueName, queue.isDurable());
}
} else {
throw new WebApplicationException(Response.status(412).type("text/plain").entity("Queue already exists.").build());
}
} finally {
try {
session.close();
} catch (Exception ignored) {
}
}
URI uri = uriInfo.getRequestUriBuilder().path(queueName).build();
return Response.created(uri).build();
} catch (Exception e) {
if (e instanceof WebApplicationException)
throw (WebApplicationException) e;
throw new WebApplicationException(e, Response.serverError().type("text/plain").entity("Failed to create queue.").build());
}
}
use of org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration in project activemq-artemis by apache.
the class JMSServerManagerImpl method deploy.
private void deploy() throws Exception {
if (config == null) {
return;
}
List<ConnectionFactoryConfiguration> connectionFactoryConfigurations = config.getConnectionFactoryConfigurations();
for (ConnectionFactoryConfiguration cfConfig : connectionFactoryConfigurations) {
createConnectionFactory(false, cfConfig, cfConfig.getBindings());
}
List<JMSQueueConfiguration> queueConfigs = config.getQueueConfigurations();
for (JMSQueueConfiguration qConfig : queueConfigs) {
createQueue(false, qConfig.getName(), qConfig.getSelector(), qConfig.isDurable(), qConfig.getBindings());
}
List<TopicConfiguration> topicConfigs = config.getTopicConfigurations();
for (TopicConfiguration tConfig : topicConfigs) {
createTopic(false, tConfig.getName(), tConfig.getBindings());
}
}
use of org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration in project activemq-artemis by apache.
the class FileJMSConfiguration method parseConfiguration.
/**
* Parse the JMS Configuration XML
*/
public void parseConfiguration(final Node rootnode) throws Exception {
ArrayList<JMSQueueConfiguration> queues = new ArrayList<>();
ArrayList<TopicConfiguration> topics = new ArrayList<>();
Element e = (Element) rootnode;
String[] elements = new String[] { QUEUE_NODE_NAME, TOPIC_NODE_NAME };
for (String element : elements) {
NodeList children = e.getElementsByTagName(element);
for (int i = 0; i < children.getLength(); i++) {
Node node = children.item(i);
Node keyNode = node.getAttributes().getNamedItem(NAME_ATTR);
if (keyNode == null) {
ActiveMQJMSServerLogger.LOGGER.jmsConfigMissingKey(node);
continue;
}
if (node.getNodeName().equals(TOPIC_NODE_NAME)) {
topics.add(parseTopicConfiguration(node));
} else if (node.getNodeName().equals(QUEUE_NODE_NAME)) {
queues.add(parseQueueConfiguration(node));
}
}
}
String domain = XMLConfigurationUtil.getString(e, JMX_DOMAIN_NAME, ActiveMQDefaultConfiguration.getDefaultJmxDomain(), Validators.NO_CHECK);
newConfig(queues, topics, domain);
}
use of org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration in project activemq-artemis by apache.
the class JMSServerConfigParserTest method testParsing.
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testParsing() throws Exception {
Configuration config = createDefaultInVMConfig().addConnectorConfiguration("netty", new TransportConfiguration());
String conf = "activemq-jms-for-JMSServerDeployerTest.xml";
FileJMSConfiguration jmsconfig = new FileJMSConfiguration();
FileDeploymentManager deploymentManager = new FileDeploymentManager(conf);
deploymentManager.addDeployable(jmsconfig);
deploymentManager.readConfiguration();
assertEquals(1, jmsconfig.getQueueConfigurations().size());
JMSQueueConfiguration queueConfig = jmsconfig.getQueueConfigurations().get(0);
assertEquals("fullConfigurationQueue", queueConfig.getName());
assertEquals(1, jmsconfig.getTopicConfigurations().size());
TopicConfiguration topicConfig = jmsconfig.getTopicConfigurations().get(0);
assertEquals("fullConfigurationTopic", topicConfig.getName());
}
Aggregations