use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.
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();
}
use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.
the class ManagementActivationTest method testCreateConnectionFactory.
@Test
public void testCreateConnectionFactory() throws Exception {
List<String> connectorNames = new ArrayList<>();
connectorNames.add(connectorName);
ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl().setName("test").setConnectorNames(connectorNames).setBindings("/myConnectionFactory");
backupJmsServer.createConnectionFactory(true, config, "/myConnectionFactory");
boolean exception = false;
try {
context.lookup("/myConnectionFactory");
} catch (NameNotFoundException e) {
exception = true;
}
assertTrue("exception expected", exception);
liveServer.crash();
long timeout = System.currentTimeMillis() + 5000;
ConnectionFactory factory = null;
while (timeout > System.currentTimeMillis()) {
try {
factory = (ConnectionFactory) context.lookup("/myConnectionFactory");
} catch (Exception ignored) {
// ignored.printStackTrace();
}
if (factory == null) {
Thread.sleep(100);
} else {
break;
}
}
assertNotNull(factory);
}
use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.
the class OpenWireTestBase method createCF.
protected void createCF(final List<TransportConfiguration> connectorConfigs, final String... jndiBindings) throws Exception {
final int retryInterval = 1000;
final double retryIntervalMultiplier = 1.0;
final int reconnectAttempts = -1;
final int callTimeout = 30000;
List<String> connectorNames = registerConnectors(server, connectorConfigs);
String cfName = name.getMethodName();
if (cfName == null) {
cfName = "cfOpenWire";
}
ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl().setName(cfName).setConnectorNames(connectorNames).setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryIntervalMultiplier).setCallTimeout(callTimeout).setReconnectAttempts(reconnectAttempts);
jmsServer.createConnectionFactory(false, configuration, jndiBindings);
}
use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.
the class StoreConfigTest method testCreateCF.
@Test
public void testCreateCF() throws Exception {
server.getConfiguration().getConnectorConfigurations().put("tst", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
server.getConfiguration().getConnectorConfigurations().put("np", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
List<String> transportConfigurations = new ArrayList<>();
transportConfigurations.add("tst");
ConnectionFactoryConfigurationImpl factCFG = (ConnectionFactoryConfigurationImpl) new ConnectionFactoryConfigurationImpl().setName("tst").setConnectorNames(transportConfigurations);
jmsServer.createConnectionFactory(true, factCFG, "/someCF", "/someCF2");
ConnectionFactoryConfigurationImpl nonPersisted = (ConnectionFactoryConfigurationImpl) new ConnectionFactoryConfigurationImpl().setName("np").setConnectorNames(transportConfigurations);
jmsServer.createConnectionFactory(false, nonPersisted, "/nonPersisted");
try {
jmsServer.addConnectionFactoryToBindingRegistry("np", "/someCF");
fail("Failure expected and the API let duplicates");
} catch (NamingException expected) {
// expected
}
openCon("/someCF");
openCon("/someCF2");
openCon("/nonPersisted");
jmsServer.stop();
jmsServer.start();
openCon("/someCF");
openCon("/someCF2");
assertNullJNDI("/nonPersisted");
jmsServer.stop();
jmsServer.start();
jmsServer.addConnectionFactoryToBindingRegistry("tst", "/newJNDI");
try {
jmsServer.addConnectionFactoryToBindingRegistry("tst", "/newJNDI");
fail("Failure expected and the API let duplicates");
} catch (NamingException expected) {
// expected
}
openCon("/someCF");
openCon("/someCF2");
openCon("/newJNDI");
assertNullJNDI("/nonPersisted");
jmsServer.stop();
assertNullJNDI("/newJNDI");
jmsServer.start();
openCon("/someCF");
openCon("/someCF2");
openCon("/newJNDI");
}
use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.
the class StoreConfigTest method testCreateTopic.
@Test
public void testCreateTopic() throws Exception {
server.getConfiguration().getConnectorConfigurations().put("tst", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
server.getConfiguration().getConnectorConfigurations().put("np", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
List<String> transportConfigurations = new ArrayList<>();
transportConfigurations.add("tst");
ConnectionFactoryConfigurationImpl factCFG = (ConnectionFactoryConfigurationImpl) new ConnectionFactoryConfigurationImpl().setName("tst").setConnectorNames(transportConfigurations);
jmsServer.createConnectionFactory(true, factCFG, "/someCF");
assertTrue(jmsServer.createTopic(true, "topicOne", "/t1", "/t.1"));
assertTrue(jmsServer.createTopic(false, "topicTwo", "/t2", "/t.2"));
assertFalse(jmsServer.createTopic(false, "topicOne", "/z1", "z2"));
assertNullJNDI("/z1");
assertNullJNDI("/z2");
checkDestination("/t1");
checkDestination("/t.1");
checkDestination("/t2");
checkDestination("/t.2");
jmsServer.stop();
assertNullJNDI("/t1");
assertNullJNDI("/t.1");
assertNullJNDI("/t2");
assertNullJNDI("/t.2");
jmsServer.start();
checkDestination("/t1");
checkDestination("/t.1");
assertNullJNDI("/t2");
assertNullJNDI("/t.2");
jmsServer.addTopicToBindingRegistry("topicOne", "/tI");
jmsServer.stop();
jmsServer.start();
checkDestination("/tI");
checkDestination("/t1");
checkDestination("/t.1");
assertNullJNDI("/t2");
assertNullJNDI("/t.2");
assertTrue(jmsServer.removeTopicFromBindingRegistry("topicOne", "/tI"));
assertFalse(jmsServer.removeTopicFromBindingRegistry("topicOne", "nothing"));
assertFalse(jmsServer.removeTopicFromBindingRegistry("nothing", "nothing"));
assertFalse(jmsServer.removeTopicFromBindingRegistry("nothing"));
assertNullJNDI("/tI");
checkDestination("/t1");
checkDestination("/t.1");
jmsServer.stop();
jmsServer.start();
assertNullJNDI("/tI");
checkDestination("/t1");
checkDestination("/t.1");
jmsServer.removeTopicFromBindingRegistry("topicOne");
assertTrue(jmsServer.createTopic(true, "topicOne", "/topicx.1", "/topicx.2"));
jmsServer.stop();
jmsServer.start();
checkDestination("/topicx.1");
checkDestination("/topicx.2");
}
Aggregations