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;
}
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;
}
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;
}
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;
}
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();
}
Aggregations