use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by rh-messaging.
the class FailoverPriorityTest method restart.
private void restart(boolean primary, int primaryID, int secondaryID, int total) throws Exception {
Thread.sleep(1000);
if (primary) {
LOG.info("Stopping " + primaryID);
stopBroker(primaryID);
Assert.assertTrue(servers[secondaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total - 1));
} else {
LOG.info("Stopping " + secondaryID);
stopBroker(secondaryID);
Assert.assertTrue(servers[primaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total - 1));
}
Thread.sleep(5000);
if (primary) {
assertAllConnectedTo(urls.get(secondaryID));
} else {
assertAllConnectedTo(urls.get(primaryID));
}
if (primary) {
Configuration config = createConfig("127.0.0.1", primaryID);
deployClusterConfiguration(config, secondaryID);
servers[primaryID] = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
servers[primaryID].start();
Assert.assertTrue(servers[primaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
Assert.assertTrue(servers[secondaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
} else {
Configuration config = createConfig("127.0.0.1", secondaryID);
deployClusterConfiguration(config, primaryID);
servers[secondaryID] = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
servers[secondaryID].start();
Assert.assertTrue(servers[primaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
Assert.assertTrue(servers[secondaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
}
Thread.sleep(5000);
assertAllConnectedTo(urls.get(primaryID));
}
use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by rh-messaging.
the class JMSConfigurationTest method testSetupJMSConfiguration.
@Test
public void testSetupJMSConfiguration() throws Exception {
Context context = new InVMNamingContext();
ActiveMQServer coreServer = new ActiveMQServerImpl(createDefaultInVMConfig());
JMSConfiguration jmsConfiguration = new JMSConfigurationImpl();
TransportConfiguration connectorConfig = new TransportConfiguration(InVMConnectorFactory.class.getName());
List<TransportConfiguration> transportConfigs = new ArrayList<>();
transportConfigs.add(connectorConfig);
ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName(RandomUtil.randomString()).setConnectorNames(registerConnectors(coreServer, transportConfigs)).setBindings("/cf/binding1", "/cf/binding2");
jmsConfiguration.getConnectionFactoryConfigurations().add(cfConfig);
JMSQueueConfigurationImpl queueConfig = new JMSQueueConfigurationImpl().setName(RandomUtil.randomString()).setDurable(false).setBindings("/queue/binding1", "/queue/binding2");
jmsConfiguration.getQueueConfigurations().add(queueConfig);
TopicConfiguration topicConfig = new TopicConfigurationImpl().setName(RandomUtil.randomString()).setBindings("/topic/binding1", "/topic/binding2");
jmsConfiguration.getTopicConfigurations().add(topicConfig);
JMSServerManager server = new JMSServerManagerImpl(coreServer, jmsConfiguration);
server.setRegistry(new JndiBindingRegistry(context));
server.start();
for (String binding : cfConfig.getBindings()) {
Object o = context.lookup(binding);
Assert.assertNotNull(o);
Assert.assertTrue(o instanceof ConnectionFactory);
ConnectionFactory cf = (ConnectionFactory) o;
Connection connection = cf.createConnection();
connection.close();
}
for (String binding : queueConfig.getBindings()) {
Object o = context.lookup(binding);
Assert.assertNotNull(o);
Assert.assertTrue(o instanceof Queue);
Queue queue = (Queue) o;
Assert.assertEquals(queueConfig.getName(), queue.getQueueName());
}
for (String binding : topicConfig.getBindings()) {
Object o = context.lookup(binding);
Assert.assertNotNull(o);
Assert.assertTrue(o instanceof Topic);
Topic topic = (Topic) o;
Assert.assertEquals(topicConfig.getName(), topic.getTopicName());
}
server.stop();
}
Aggregations