Search in sources :

Example 1 with JMSConfiguration

use of org.apache.activemq.artemis.jms.server.config.JMSConfiguration in project narayana by jbosstm.

the class JmsHelper method getJmsConfiguration.

private JMSConfiguration getJmsConfiguration() {
    JMSConfiguration jmsConfiguration = new JMSConfigurationImpl();
    jmsConfiguration.getConnectionFactoryConfigurations().add(getConnectionFactoryConfiguration());
    jmsConfiguration.getQueueConfigurations().add(getQueueConfiguration());
    return jmsConfiguration;
}
Also used : JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)

Example 2 with JMSConfiguration

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

the class StompWithClientIdValidationTest method createServer.

@Override
protected JMSServerManager createServer() throws Exception {
    Configuration config = createBasicConfig().setSecurityEnabled(isSecurityEnabled()).setPersistenceEnabled(isPersistenceEnabled()).addAcceptorConfiguration("stomp", "tcp://localhost:61613?enabledProtocols=STOMP").addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration()) {

        @Override
        public String validateUser(String user, String password, RemotingConnection remotingConnection) {
            String validatedUser = super.validateUser(user, password, remotingConnection);
            if (validatedUser == null) {
                return null;
            }
            if ("STOMP".equals(remotingConnection.getProtocolName())) {
                final String clientId = remotingConnection.getClientID();
                /*
                * perform some kind of clientId validation, e.g. check presence or format
                */
                if (clientId == null || clientId.length() == 0) {
                    System.err.println("ClientID not set!");
                    return null;
                }
            }
            return validatedUser;
        }
    };
    securityManager.getConfiguration().addUser(defUser, defPass);
    ActiveMQServer activeMqServer = addServer(ActiveMQServers.newActiveMQServer(config, ManagementFactory.getPlatformMBeanServer(), securityManager));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    server = new JMSServerManagerImpl(activeMqServer, jmsConfig);
    server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
    return server;
}
Also used : JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)

Example 3 with JMSConfiguration

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

the class StompTestBase method createServer.

/**
 * @return
 * @throws Exception
 */
protected JMSServerManager createServer() throws Exception {
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME + "," + MQTTProtocolManagerFactory.MQTT_PROTOCOL_NAME);
    params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
    params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
    if (isEnableStompMessageId()) {
        params.put(TransportConstants.STOMP_ENABLE_MESSAGE_ID, true);
    }
    if (getStompMinLargeMessageSize() != null) {
        params.put(TransportConstants.STOMP_MIN_LARGE_MESSAGE_SIZE, 2048);
    }
    TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
    Configuration config = createBasicConfig().setSecurityEnabled(isSecurityEnabled()).setPersistenceEnabled(isPersistenceEnabled()).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName())).setConnectionTtlCheckInterval(500);
    if (getIncomingInterceptors() != null) {
        config.setIncomingInterceptorClassNames(getIncomingInterceptors());
    }
    if (getOutgoingInterceptors() != null) {
        config.setOutgoingInterceptorClassNames(getOutgoingInterceptors());
    }
    config.setPersistenceEnabled(true);
    ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));
    if (isSecurityEnabled()) {
        ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) activeMQServer.getSecurityManager();
        final String role = "testRole";
        securityManager.getConfiguration().addRole(defUser, role);
        config.getSecurityRoles().put("#", new HashSet<Role>() {

            {
                add(new Role(role, true, true, true, true, true, true, true, true, true, true));
            }
        });
    }
    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;
}
Also used : JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) HashMap(java.util.HashMap) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) NettyAcceptorFactory(org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) Role(org.apache.activemq.artemis.core.security.Role) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) JMSQueueConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl) InVMAcceptorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory) TopicConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.TopicConfigurationImpl) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)

Example 4 with JMSConfiguration

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

the class StompWebSocketTest method createServer.

/**
 * @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;
}
Also used : JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) HashMap(java.util.HashMap) NettyAcceptorFactory(org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) InVMAcceptorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory)

Example 5 with JMSConfiguration

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

the class HornetQProtocolManagerTest method setUp.

@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();
}
Also used : JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) EmbeddedJMS(org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS) Configuration(org.apache.activemq.artemis.core.config.Configuration) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) JMSQueueConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl) Before(org.junit.Before)

Aggregations

JMSConfiguration (org.apache.activemq.artemis.jms.server.config.JMSConfiguration)10 JMSConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)10 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