Search in sources :

Example 51 with JMSConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by rh-messaging.

the class FanoutTransportBrokerTest method setUp.

@Before
public void setUp() throws Exception {
    Configuration config0 = createConfig(0);
    server = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    Configuration config1 = createConfig(1);
    remoteServer = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server.start();
    remoteServer.start();
}
Also used : EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) Before(org.junit.Before)

Example 52 with JMSConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by rh-messaging.

the class EmbeddedBrokerTestSupport method createArtemisBroker.

public EmbeddedJMS createArtemisBroker() throws Exception {
    Configuration config0 = createConfig("localhost", 0);
    EmbeddedJMS newbroker = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    return newbroker;
}
Also used : EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)

Example 53 with JMSConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by rh-messaging.

the class FailoverTransportBrokerTest method setUp.

@Before
public void setUp() throws Exception {
    Configuration config0 = createConfig(0);
    server = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    Configuration config1 = createConfig(1);
    remoteServer = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server.start();
    remoteServer.start();
}
Also used : EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) Before(org.junit.Before)

Example 54 with JMSConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by rh-messaging.

the class FailoverUpdateURIsTest method testUpdateURIsViaFile.

@Test
public void testUpdateURIsViaFile() throws Exception {
    String targetDir = "target/testUpdateURIsViaFile";
    new File(targetDir).mkdir();
    File updateFile = new File(targetDir + "/updateURIsFile.txt");
    LOG.info(updateFile);
    LOG.info(updateFile.toURI());
    LOG.info(updateFile.getAbsoluteFile());
    LOG.info(updateFile.getAbsoluteFile().toURI());
    FileOutputStream out = new FileOutputStream(updateFile);
    out.write(firstTcpUri.getBytes());
    out.close();
    Configuration config0 = createConfig(0);
    server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    server0.start();
    // no failover uri's to start with, must be read from file...
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:()?updateURIsURL=file:///" + updateFile.getAbsoluteFile());
    connection = cf.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue theQueue = session.createQueue(QUEUE_NAME);
    MessageProducer producer = session.createProducer(theQueue);
    MessageConsumer consumer = session.createConsumer(theQueue);
    Message message = session.createTextMessage("Test message");
    producer.send(message);
    Message msg = consumer.receive(2000);
    Assert.assertNotNull(msg);
    server0.stop();
    server0 = null;
    Configuration config1 = createConfig(10);
    server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server1.start();
    // add the transport uri for broker number 2
    out = new FileOutputStream(updateFile, true);
    out.write(",".getBytes());
    out.write(secondTcpUri.toString().getBytes());
    out.close();
    producer.send(message);
    msg = consumer.receive(2000);
    Assert.assertNotNull(msg);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) MessageConsumer(javax.jms.MessageConsumer) Configuration(org.apache.activemq.artemis.core.config.Configuration) Message(javax.jms.Message) FileOutputStream(java.io.FileOutputStream) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) MessageProducer(javax.jms.MessageProducer) File(java.io.File) Queue(javax.jms.Queue) Session(javax.jms.Session) Test(org.junit.Test) OpenwireArtemisBaseTest(org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest)

Example 55 with JMSConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl in project activemq-artemis by rh-messaging.

the class FailoverUpdateURIsTest method testAutoUpdateURIs.

@Test
public void testAutoUpdateURIs() throws Exception {
    Map<String, String> params = new HashMap<>();
    params.put("updateClusterClients", "true");
    Configuration config0 = createConfig("localhost", 0, params);
    deployClusterConfiguration(config0, 10);
    server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
    server0.start();
    Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 1));
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + firstTcpUri + ")");
    connection = cf.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue theQueue = session.createQueue(QUEUE_NAME);
    MessageProducer producer = session.createProducer(theQueue);
    MessageConsumer consumer = session.createConsumer(theQueue);
    Message message = session.createTextMessage("Test message");
    producer.send(message);
    Message msg = consumer.receive(4000);
    Assert.assertNotNull(msg);
    Configuration config1 = createConfig(10);
    deployClusterConfiguration(config1, 0);
    server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
    server1.start();
    Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    TimeUnit.SECONDS.sleep(4);
    LOG.info("stopping brokerService 1");
    server0.stop();
    server0 = null;
    producer.send(message);
    msg = consumer.receive(4000);
    Assert.assertNotNull(msg);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) MessageConsumer(javax.jms.MessageConsumer) Configuration(org.apache.activemq.artemis.core.config.Configuration) Message(javax.jms.Message) HashMap(java.util.HashMap) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) MessageProducer(javax.jms.MessageProducer) Queue(javax.jms.Queue) Session(javax.jms.Session) Test(org.junit.Test) OpenwireArtemisBaseTest(org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest)

Aggregations

JMSConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)62 Configuration (org.apache.activemq.artemis.core.config.Configuration)57 EmbeddedJMS (org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS)52 Before (org.junit.Before)19 Test (org.junit.Test)16 OpenwireArtemisBaseTest (org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest)14 HashMap (java.util.HashMap)10 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)8 JMSConfiguration (org.apache.activemq.artemis.jms.server.config.JMSConfiguration)8 MessageProducer (javax.jms.MessageProducer)6 Queue (javax.jms.Queue)6 Session (javax.jms.Session)6 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)6 JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)6 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)6 InVMNamingContext (org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)6 ConnectionFactoryConfiguration (org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)5 JMSQueueConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl)5 URI (java.net.URI)4 Connection (javax.jms.Connection)4