Search in sources :

Example 6 with JMSConfiguration

use of org.apache.activemq.artemis.jms.server.config.JMSConfiguration 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 JMSConfiguration

use of org.apache.activemq.artemis.jms.server.config.JMSConfiguration in project spring-boot by spring-projects.

the class ArtemisEmbeddedServerConfiguration method artemisJmsConfiguration.

@Bean
@ConditionalOnMissingBean
JMSConfiguration artemisJmsConfiguration(ObjectProvider<JMSQueueConfiguration> queuesConfiguration, ObjectProvider<TopicConfiguration> topicsConfiguration) {
    JMSConfiguration configuration = new JMSConfigurationImpl();
    addAll(configuration.getQueueConfigurations(), queuesConfiguration);
    addAll(configuration.getTopicConfigurations(), topicsConfiguration);
    addQueues(configuration, this.properties.getEmbedded().getQueues());
    addTopics(configuration, this.properties.getEmbedded().getTopics());
    return configuration;
}
Also used : JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 8 with JMSConfiguration

use of org.apache.activemq.artemis.jms.server.config.JMSConfiguration in project spring-boot by spring-projects.

the class ArtemisEmbeddedServerConfiguration method artemisJmsConfiguration.

@Bean
@ConditionalOnMissingBean
public JMSConfiguration artemisJmsConfiguration() {
    JMSConfiguration configuration = new JMSConfigurationImpl();
    addAll(configuration.getQueueConfigurations(), this.queuesConfiguration);
    addAll(configuration.getTopicConfigurations(), this.topicsConfiguration);
    addQueues(configuration, this.properties.getEmbedded().getQueues());
    addTopics(configuration, this.properties.getEmbedded().getTopics());
    return configuration;
}
Also used : JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 9 with JMSConfiguration

use of org.apache.activemq.artemis.jms.server.config.JMSConfiguration 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 10 with JMSConfiguration

use of org.apache.activemq.artemis.jms.server.config.JMSConfiguration 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();
}
Also used : InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext) Context(javax.naming.Context) JMSServerManager(org.apache.activemq.artemis.jms.server.JMSServerManager) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) ArrayList(java.util.ArrayList) Connection(javax.jms.Connection) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) TopicConfiguration(org.apache.activemq.artemis.jms.server.config.TopicConfiguration) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ConnectionFactory(javax.jms.ConnectionFactory) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) 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) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) Topic(javax.jms.Topic) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) Queue(javax.jms.Queue) TopicConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.TopicConfigurationImpl) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext) Test(org.junit.Test)

Aggregations

JMSConfiguration (org.apache.activemq.artemis.jms.server.config.JMSConfiguration)11 JMSConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)11 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)7 Configuration (org.apache.activemq.artemis.core.config.Configuration)6 JMSQueueConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl)6 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)5 JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)4 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)4 ConnectionFactoryConfiguration (org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)4 ConnectionFactoryConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl)4 InVMNamingContext (org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)4 Before (org.junit.Before)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 InVMAcceptorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory)2 NettyAcceptorFactory (org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory)2 TopicConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.TopicConfigurationImpl)2 EmbeddedJMS (org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS)2 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)2