Search in sources :

Example 6 with ConnectionFactoryConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.

the class MultipleProducersPagingTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    executor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory());
    AddressSettings addressSettings = new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE).setPageSizeBytes(50000).setMaxSizeBytes(404850);
    Configuration config = createBasicConfig().setPersistenceEnabled(false).setAddressesSettings(Collections.singletonMap("#", addressSettings)).setAcceptorConfigurations(Collections.singleton(new TransportConfiguration(NettyAcceptorFactory.class.getName()))).setConnectorConfigurations(Collections.singletonMap("netty", new TransportConfiguration(NettyConnectorFactory.class.getName())));
    final JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    jmsConfig.getConnectionFactoryConfigurations().add(new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(Arrays.asList("netty")).setBindings("/cf"));
    jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName("simple").setSelector("").setDurable(false).setBindings("/queue/simple"));
    jmsServer = new EmbeddedJMS();
    jmsServer.setConfiguration(config);
    jmsServer.setJmsConfiguration(jmsConfig);
    jmsServer.start();
    cf = (ConnectionFactory) jmsServer.lookup("/cf");
    queue = (Queue) jmsServer.lookup("/queue/simple");
    barrierLatch = new CyclicBarrier(PRODUCERS + 1);
    runnersLatch = new CountDownLatch(PRODUCERS + 1);
    msgReceived = new AtomicLong(0);
    msgSent = new AtomicLong(0);
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) AtomicLong(java.util.concurrent.atomic.AtomicLong) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) NettyConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) JMSQueueConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) CountDownLatch(java.util.concurrent.CountDownLatch) CyclicBarrier(java.util.concurrent.CyclicBarrier) Before(org.junit.Before)

Example 7 with ConnectionFactoryConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.

the class JMSDynamicConfigTest method testStart.

// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testStart() throws Exception {
    ArrayList<String> connectors = new ArrayList<>();
    connectors.add("invm");
    ConnectionFactoryConfiguration cfg = new ConnectionFactoryConfigurationImpl().setName("tst").setConnectorNames(connectors).setBindings("tt");
    jmsServer.createConnectionFactory(true, cfg, "tst");
    assertNotNull(namingContext.lookup("tst"));
    jmsServer.removeConnectionFactoryFromBindingRegistry("tst");
    try {
        namingContext.lookup("tst");
        fail("failure expected");
    } catch (NamingException excepted) {
    }
    jmsServer.stop();
    OperationContextImpl.clearContext();
    jmsServer.start();
    try {
        namingContext.lookup("tst");
        fail("failure expected");
    } catch (NamingException excepted) {
    }
}
Also used : ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) ArrayList(java.util.ArrayList) NamingException(javax.naming.NamingException) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) Test(org.junit.Test)

Example 8 with ConnectionFactoryConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project camel by apache.

the class Jms2TestSupport method configureBroker.

protected void configureBroker(EmbeddedJMS broker) throws Exception {
    Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setJournalDirectory("target/data/journal").setSecurityEnabled(false).addAcceptorConfiguration("connector", brokerUri + "?protocols=CORE,AMQP,HORNETQ,OPENWIRE").addAcceptorConfiguration("vm", "vm://broker").addConnectorConfiguration("connector", new TransportConfiguration(NettyConnectorFactory.class.getName()));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(Arrays.asList("connector")).setBindings("cf");
    jmsConfig.getConnectionFactoryConfigurations().add(cfConfig);
    JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl().setName("queue1").setDurable(false).setBindings("queue/queue1");
    jmsConfig.getQueueConfigurations().add(queueConfig);
    broker.setConfiguration(configuration).setJmsConfiguration(jmsConfig);
}
Also used : JMSQueueConfiguration(org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) JMSQueueConfiguration(org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) JMSQueueConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) JMSQueueConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)

Example 9 with ConnectionFactoryConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.

the class HornetQProtocolManagerTest method testLegacy2.

/**
 * This test will use an ArtemisConnectionFactory with clientProtocolManager=
 */
@Test
public void testLegacy2() throws Exception {
    ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl();
    configuration.setConnectorNames("legacy");
    configuration.setName("legacy");
    configuration.setProtocolManagerFactoryStr(HornetQClientProtocolManagerFactory.class.getName());
    embeddedJMS.getJMSServerManager().createConnectionFactory(false, configuration, "legacy");
    // WORKAROUND: the 2.0.0 broker introduced addressing change and the 2.2.0 broker added compatibility for old
    // client libraries relying on the legacy prefixes. The new client being used in this test needs prefix explicitly.
    Queue queue = new ActiveMQQueue("jms.queue.testQueue");
    ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) embeddedJMS.lookup("legacy");
    Connection connection = connectionFactory.createConnection();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageProducer producer = session.createProducer(queue);
    TextMessage message = session.createTextMessage("Test");
    for (int i = 0; i < 5; i++) {
        message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), "duplicate");
        producer.send(message);
    }
    connection.start();
    MessageConsumer consumer = session.createConsumer(queue);
    TextMessage messageRec = (TextMessage) consumer.receive(5000);
    Assert.assertNotNull(messageRec);
    Assert.assertEquals("Test", messageRec.getText());
    Assert.assertNull(consumer.receiveNoWait());
    connection.close();
    connectionFactory.close();
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) MessageConsumer(javax.jms.MessageConsumer) HornetQClientProtocolManagerFactory(org.apache.activemq.artemis.core.protocol.hornetq.client.HornetQClientProtocolManagerFactory) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) Connection(javax.jms.Connection) ActiveMQQueue(org.apache.activemq.artemis.jms.client.ActiveMQQueue) MessageProducer(javax.jms.MessageProducer) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) ActiveMQQueue(org.apache.activemq.artemis.jms.client.ActiveMQQueue) Queue(javax.jms.Queue) TextMessage(javax.jms.TextMessage) Session(javax.jms.Session) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) Test(org.junit.Test)

Example 10 with ConnectionFactoryConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.

the class JMSConnectionFactoryConfigurationStorageTest method testSettingsWithConnectorConfigs.

@Test
public void testSettingsWithConnectorConfigs() throws Exception {
    createJMSStorage();
    String[] str = new String[5];
    for (int i = 0; i < 5; i++) {
        str[i] = "str" + i;
    }
    List<String> connectorConfigs = new ArrayList<>();
    Map<String, Object> liveParams = new HashMap<>();
    liveParams.put(TransportConstants.PORT_PROP_NAME, 5665);
    Map<String, Object> backupParams = new HashMap<>();
    backupParams.put(TransportConstants.PORT_PROP_NAME, 5775);
    Map<String, Object> liveParams2 = new HashMap<>();
    liveParams2.put(TransportConstants.PORT_PROP_NAME, 6665);
    ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl().setName("some-name").setConnectorNames(connectorConfigs).setBindings(str).setCallTimeout(RandomUtil.randomPositiveLong());
    List<Pair<String, String>> connectors = new ArrayList<>();
    connectors.add(new Pair<String, String>(RandomUtil.randomString(), null));
    // config.setConnectorNames(connectors);
    addSetting(new PersistedConnectionFactory(config));
    jmsJournal.stop();
    createJMSStorage();
    List<PersistedConnectionFactory> cfs = jmsJournal.recoverConnectionFactories();
    assertEquals(1, cfs.size());
    assertEquals("some-name", cfs.get(0).getName());
    assertEquals(config.getCallTimeout(), cfs.get(0).getConfig().getCallTimeout());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PersistedConnectionFactory(org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) Pair(org.apache.activemq.artemis.api.core.Pair) Test(org.junit.Test)

Aggregations

ConnectionFactoryConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl)23 ConnectionFactoryConfiguration (org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)17 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)10 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)8 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)5 JMSConfiguration (org.apache.activemq.artemis.jms.server.config.JMSConfiguration)4 JMSConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)4 JMSQueueConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl)4 PersistedConnectionFactory (org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory)3 HashMap (java.util.HashMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Connection (javax.jms.Connection)2 ConnectionFactory (javax.jms.ConnectionFactory)2 Queue (javax.jms.Queue)2 NamingException (javax.naming.NamingException)2 Configuration (org.apache.activemq.artemis.core.config.Configuration)2 JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)2 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)2 InVMNamingContext (org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)2