use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class FileConfigurationParser method parseAddressConfiguration.
protected CoreAddressConfiguration parseAddressConfiguration(final Node node) {
CoreAddressConfiguration addressConfiguration = new CoreAddressConfiguration();
String name = getAttributeValue(node, "name");
addressConfiguration.setName(name);
List<CoreQueueConfiguration> queueConfigurations = new ArrayList<>();
NodeList children = node.getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
Node child = children.item(j);
if (child.getNodeName().equals("multicast")) {
addressConfiguration.addRoutingType(RoutingType.MULTICAST);
queueConfigurations.addAll(parseQueueConfigurations((Element) child, RoutingType.MULTICAST));
} else if (child.getNodeName().equals("anycast")) {
addressConfiguration.addRoutingType(RoutingType.ANYCAST);
queueConfigurations.addAll(parseQueueConfigurations((Element) child, RoutingType.ANYCAST));
}
}
for (CoreQueueConfiguration coreQueueConfiguration : queueConfigurations) {
coreQueueConfiguration.setAddress(name);
}
addressConfiguration.setQueueConfigurations(queueConfigurations);
return addressConfiguration;
}
use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration 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.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class LargeMessageOverReplicationTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
ruleFired.setCount(1);
messageChunkCount = 0;
TransportConfiguration liveConnector = TransportConfigurationUtils.getNettyConnector(true, 0);
TransportConfiguration liveAcceptor = TransportConfigurationUtils.getNettyAcceptor(true, 0);
TransportConfiguration backupConnector = TransportConfigurationUtils.getNettyConnector(false, 0);
TransportConfiguration backupAcceptor = TransportConfigurationUtils.getNettyAcceptor(false, 0);
Configuration backupConfig = createDefaultInVMConfig().setBindingsDirectory(getBindingsDir(0, true)).setJournalDirectory(getJournalDir(0, true)).setPagingDirectory(getPageDir(0, true)).setLargeMessagesDirectory(getLargeMessagesDir(0, true));
Configuration liveConfig = createDefaultInVMConfig();
ReplicatedBackupUtils.configureReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, liveAcceptor);
liveServer = createServer(liveConfig);
liveServer.getConfiguration().addQueueConfiguration(new CoreQueueConfiguration().setName("Queue").setAddress("Queue"));
liveServer.start();
waitForServerToStart(liveServer);
backupServer = createServer(backupConfig);
backupServer.start();
waitForServerToStart(backupServer);
// Just to make sure the expression worked
Assert.assertEquals(10000, factory.getMinLargeMessageSize());
Assert.assertEquals(10000, factory.getProducerWindowSize());
Assert.assertEquals(100, factory.getRetryInterval());
Assert.assertEquals(-1, factory.getReconnectAttempts());
Assert.assertTrue(factory.isHA());
connection = (ActiveMQConnection) factory.createConnection();
waitForRemoteBackup(connection.getSessionFactory(), 30);
session = connection.createSession(true, Session.SESSION_TRANSACTED);
queue = session.createQueue("Queue");
producer = session.createProducer(queue);
}
use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class FileConfigurationTest method verifyAddresses.
private void verifyAddresses() {
assertEquals(3, conf.getAddressConfigurations().size());
// Addr 1
CoreAddressConfiguration addressConfiguration = conf.getAddressConfigurations().get(0);
assertEquals("addr1", addressConfiguration.getName());
Set<RoutingType> routingTypes = new HashSet<>();
routingTypes.add(RoutingType.ANYCAST);
assertEquals(routingTypes, addressConfiguration.getRoutingTypes());
assertEquals(2, addressConfiguration.getQueueConfigurations().size());
// Addr 1 Queue 1
CoreQueueConfiguration queueConfiguration = addressConfiguration.getQueueConfigurations().get(0);
assertEquals("q1", queueConfiguration.getName());
assertFalse(queueConfiguration.isDurable());
assertEquals("color='blue'", queueConfiguration.getFilterString());
assertEquals(ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers(), queueConfiguration.getPurgeOnNoConsumers());
assertEquals("addr1", queueConfiguration.getAddress());
assertEquals(ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), queueConfiguration.getMaxConsumers());
// Addr 1 Queue 2
queueConfiguration = addressConfiguration.getQueueConfigurations().get(1);
assertEquals("q2", queueConfiguration.getName());
assertTrue(queueConfiguration.isDurable());
assertEquals("color='green'", queueConfiguration.getFilterString());
assertEquals(Queue.MAX_CONSUMERS_UNLIMITED, queueConfiguration.getMaxConsumers());
assertFalse(queueConfiguration.getPurgeOnNoConsumers());
assertEquals("addr1", queueConfiguration.getAddress());
// Addr 2
addressConfiguration = conf.getAddressConfigurations().get(1);
assertEquals("addr2", addressConfiguration.getName());
routingTypes = new HashSet<>();
routingTypes.add(RoutingType.MULTICAST);
assertEquals(routingTypes, addressConfiguration.getRoutingTypes());
assertEquals(2, addressConfiguration.getQueueConfigurations().size());
// Addr 2 Queue 1
queueConfiguration = addressConfiguration.getQueueConfigurations().get(0);
assertEquals("q3", queueConfiguration.getName());
assertTrue(queueConfiguration.isDurable());
assertEquals("color='red'", queueConfiguration.getFilterString());
assertEquals(10, queueConfiguration.getMaxConsumers());
assertEquals(ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers(), queueConfiguration.getPurgeOnNoConsumers());
assertEquals("addr2", queueConfiguration.getAddress());
// Addr 2 Queue 2
queueConfiguration = addressConfiguration.getQueueConfigurations().get(1);
assertEquals("q4", queueConfiguration.getName());
assertTrue(queueConfiguration.isDurable());
assertNull(queueConfiguration.getFilterString());
assertEquals(ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), queueConfiguration.getMaxConsumers());
assertTrue(queueConfiguration.getPurgeOnNoConsumers());
assertEquals("addr2", queueConfiguration.getAddress());
// Addr 3
addressConfiguration = conf.getAddressConfigurations().get(2);
assertEquals("addr2", addressConfiguration.getName());
routingTypes = new HashSet<>();
routingTypes.add(RoutingType.MULTICAST);
routingTypes.add(RoutingType.ANYCAST);
assertEquals(routingTypes, addressConfiguration.getRoutingTypes());
}
use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class MQTTTest method testBrokerRestartAfterSubHashWithConfigurationQueues.
@Test(timeout = 60 * 1000)
public void testBrokerRestartAfterSubHashWithConfigurationQueues() throws Exception {
// Add some pre configured queues
CoreQueueConfiguration coreQueueConfiguration = new CoreQueueConfiguration();
coreQueueConfiguration.setName("DLQ");
coreQueueConfiguration.setRoutingType(RoutingType.ANYCAST);
coreQueueConfiguration.setAddress("DLA");
CoreAddressConfiguration coreAddressConfiguration = new CoreAddressConfiguration();
coreAddressConfiguration.setName("DLA");
coreAddressConfiguration.addRoutingType(RoutingType.ANYCAST);
coreAddressConfiguration.addQueueConfiguration(coreQueueConfiguration);
getServer().getConfiguration().getAddressConfigurations().add(coreAddressConfiguration);
getServer().stop();
getServer().start();
getServer().waitForActivation(10, TimeUnit.SECONDS);
for (int i = 0; i < 2; i++) {
MQTT mqtt = createMQTTConnection("myClient", false);
BlockingConnection connection = mqtt.blockingConnection();
connection.connect();
connection.subscribe(new Topic[] { new Topic("#", QoS.AT_MOST_ONCE) });
connection.disconnect();
getServer().stop();
getServer().start();
getServer().waitForActivation(10, TimeUnit.SECONDS);
}
}
Aggregations