org.apache.activemq.artemis.jms.server.config.JMSConfiguration

Here are the examples of the java api class org.apache.activemq.artemis.jms.server.config.JMSConfiguration taken from open source projects.

1. HornetQProtocolManagerTest#setUp()

Project: activemq-artemis
File: HornetQProtocolManagerTest.java
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration configuration = createDefaultConfig(false);
    configuration.setPersistenceEnabled(false);
    configuration.getAcceptorConfigurations().clear();
    configuration.addAcceptorConfiguration("legacy", "tcp://localhost:61616?protocols=HORNETQ").addAcceptorConfiguration("corepr", "tcp://localhost:61617?protocols=CORE");
    configuration.addConnectorConfiguration("legacy", "tcp://localhost:61616");
    JMSConfiguration jmsConfiguration = new JMSConfigurationImpl();
    jmsConfiguration.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName("testQueue").setBindings("testQueue"));
    embeddedJMS = new EmbeddedJMS();
    embeddedJMS.setConfiguration(configuration);
    embeddedJMS.setJmsConfiguration(jmsConfiguration);
    embeddedJMS.start();
}

2. StompV11TestBase#createServer()

Project: activemq-artemis
File: StompV11TestBase.java
/**
    * @return
    * @throws Exception
    */
protected JMSServerManager createServer() throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
    Configuration config = createBasicConfig().setPersistenceEnabled(persistenceEnabled).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(getQueueName()).setBindings(getQueueName()));
    jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl().setName(getTopicName()).setBindings(getTopicName()));
    server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
    server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
    return server;
}

3. StompWebSocketTest#createServer()

Project: activemq-artemis
File: StompWebSocketTest.java
/**
    * @return
    * @throws Exception
    */
private JMSServerManager createServer() throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT + 1);
    TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
    Configuration config = createBasicConfig().addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName())).addQueueConfiguration(new CoreQueueConfiguration().setAddress(getQueueName()).setName(getQueueName()).setDurable(false));
    ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
    server.setRegistry(null);
    return server;
}

4. StompTestBase#createServer()

Project: activemq-artemis
File: StompTestBase.java
/**
    * @return
    * @throws Exception
    */
protected JMSServerManager createServer() throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
    TransportConfiguration allTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName());
    Configuration config = createBasicConfig().setPersistenceEnabled(false).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    config.addAcceptorConfiguration(allTransport);
    ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(getQueueName()).setDurable(false).setBindings(getQueueName()));
    jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl().setName(getTopicName()).setBindings(getTopicName()));
    server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
    server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
    return server;
}

5. ExtraStompTest#createServerWithStompInterceptor()

Project: activemq-artemis
File: ExtraStompTest.java
protected JMSServerManager createServerWithStompInterceptor(List<String> stompIncomingInterceptor, List<String> stompOutgoingInterceptor) throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    TransportConfiguration stompTransport = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
    Configuration config = createBasicConfig().setPersistenceEnabled(false).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)).setIncomingInterceptorClassNames(stompIncomingInterceptor).setOutgoingInterceptorClassNames(stompOutgoingInterceptor);
    ActiveMQServer hornetQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(getQueueName()).setDurable(false).setBindings(getQueueName()));
    jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl().setName(getTopicName()).setBindings(getTopicName()));
    server = new JMSServerManagerImpl(hornetQServer, jmsConfig);
    server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
    return server;
}

6. ExtraStompTest#createServerWithExtraStompOptions()

Project: activemq-artemis
File: ExtraStompTest.java
protected JMSServerManager createServerWithExtraStompOptions(String ttl, Boolean enableMessageID) throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    if (ttl != null) {
        params.put(TransportConstants.CONNECTION_TTL, ttl);
    }
    if (enableMessageID != null) {
        params.put(TransportConstants.STOMP_ENABLE_MESSAGE_ID, enableMessageID);
    }
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    TransportConfiguration stompTransport = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
    Configuration config = createBasicConfig().setPersistenceEnabled(false).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
    ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(getQueueName()).setDurable(false).setBindings(getQueueName()));
    jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl().setName(getTopicName()).setBindings(getTopicName()));
    server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
    server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
    return server;
}

7. ExtraStompTest#createPersistentServerWithStompMinLargeSize()

Project: activemq-artemis
File: ExtraStompTest.java
protected JMSServerManager createPersistentServerWithStompMinLargeSize(int sz) throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    params.put(TransportConstants.STOMP_MIN_LARGE_MESSAGE_SIZE, sz);
    TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
    Configuration config = createBasicConfig().setPersistenceEnabled(true).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(getQueueName()).setBindings(getQueueName()));
    jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl().setName(getTopicName()).setBindings(getTopicName()));
    server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
    server.setRegistry(new JndiBindingRegistry((new InVMNamingContext())));
    return server;
}

8. ArtemisEmbeddedServerConfiguration#artemisJmsConfiguration()

Project: spring-boot
File: ArtemisEmbeddedServerConfiguration.java
@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;
}

9. MultipleProducersPagingTest#setUp()

Project: activemq-artemis
File: MultipleProducersPagingTest.java
@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);
}

10. JMSConfigurationTest#testSetupJMSConfiguration()

Project: activemq-artemis
File: JMSConfigurationTest.java
@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();
}

11. ManualReconnectionToSingleServerTest#setUp()

Project: activemq-artemis
File: ManualReconnectionToSingleServerTest.java
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    context = new InVMNamingContext();
    server = createServer(false, createDefaultNettyConfig());
    JMSConfiguration configuration = new JMSConfigurationImpl();
    serverManager = new JMSServerManagerImpl(server, configuration);
    serverManager.setRegistry(new JndiBindingRegistry(context));
    configuration.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(QUEUE_NAME).setBindings(QUEUE_NAME));
    ArrayList<TransportConfiguration> configs = new ArrayList<>();
    configs.add(new TransportConfiguration(NETTY_CONNECTOR_FACTORY));
    ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(registerConnectors(server, configs)).setBindings("/cf").setRetryInterval(1000).setReconnectAttempts(-1);
    configuration.getConnectionFactoryConfigurations().add(cfConfig);
    serverManager.start();
    listener = new Listener();
    exceptionLatch = new CountDownLatch(1);
    reconnectionLatch = new CountDownLatch(1);
    allMessagesReceived = new CountDownLatch(1);
}

12. EmbeddedExample#main()

Project: activemq-artemis
File: EmbeddedExample.java
public static void main(final String[] args) throws Exception {
    // Step 1. Create ActiveMQ Artemis core configuration, and set the properties accordingly
    Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setJournalDirectory("target/data/journal").setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(NettyAcceptorFactory.class.getName())).addConnectorConfiguration("connector", new TransportConfiguration(NettyConnectorFactory.class.getName()));
    // Step 2. Create the JMS configuration
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    // Step 3. Configure the JMS ConnectionFactory
    ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(Arrays.asList("connector")).setBindings("cf");
    jmsConfig.getConnectionFactoryConfigurations().add(cfConfig);
    // Step 4. Configure the JMS Queue
    JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl().setName("queue1").setDurable(false).setBindings("queue/queue1");
    jmsConfig.getQueueConfigurations().add(queueConfig);
    // Step 5. Start the JMS Server using the ActiveMQ Artemis core server and the JMS configuration
    EmbeddedJMS jmsServer = new EmbeddedJMS().setConfiguration(configuration).setJmsConfiguration(jmsConfig).start();
    System.out.println("Started Embedded JMS Server");
    // Step 6. Lookup JMS resources defined in the configuration
    ConnectionFactory cf = (ConnectionFactory) jmsServer.lookup("cf");
    Queue queue = (Queue) jmsServer.lookup("queue/queue1");
    // Step 7. Send and receive a message using JMS API
    Connection connection = null;
    try {
        connection = cf.createConnection();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(queue);
        TextMessage message = session.createTextMessage("Hello sent at " + new Date());
        System.out.println("Sending message: " + message.getText());
        producer.send(message);
        MessageConsumer messageConsumer = session.createConsumer(queue);
        connection.start();
        TextMessage messageReceived = (TextMessage) messageConsumer.receive(1000);
        System.out.println("Received message:" + messageReceived.getText());
    } finally {
        if (connection != null) {
            connection.close();
        }
        // Step 11. Stop the JMS server
        jmsServer.stop();
        System.out.println("Stopped the JMS Server");
    }
}