Search in sources :

Example 11 with TransportConfiguration

use of org.apache.activemq.artemis.api.core.TransportConfiguration in project wildfly by wildfly.

the class TransportConfigOperationHandlers method processConnectors.

/**
     * Process the connector information.
     *
     * @param context       the operation context
     * @param configuration the ActiveMQ configuration
     * @param params        the detyped operation parameters
     * @param bindings      the referenced socket bindings
     * @throws OperationFailedException
     */
static void processConnectors(final OperationContext context, final Configuration configuration, final ModelNode params, final Set<String> bindings) throws OperationFailedException {
    final Map<String, TransportConfiguration> connectors = new HashMap<String, TransportConfiguration>();
    if (params.hasDefined(CONNECTOR)) {
        for (final Property property : params.get(CONNECTOR).asPropertyList()) {
            final String connectorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
            ModelNode socketBinding = GenericTransportDefinition.SOCKET_BINDING.resolveModelAttribute(context, config);
            if (socketBinding.isDefined()) {
                bindings.add(socketBinding.asString());
                // uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
                parameters.put(GenericTransportDefinition.SOCKET_BINDING.getName(), socketBinding.asString());
            }
            final String clazz = FACTORY_CLASS.resolveModelAttribute(context, config).asString();
            connectors.put(connectorName, new TransportConfiguration(clazz, parameters, connectorName));
        }
    }
    if (params.hasDefined(REMOTE_CONNECTOR)) {
        for (final Property property : params.get(REMOTE_CONNECTOR).asPropertyList()) {
            final String connectorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
            final String binding = config.get(RemoteTransportDefinition.SOCKET_BINDING.getName()).asString();
            bindings.add(binding);
            // uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
            parameters.put(RemoteTransportDefinition.SOCKET_BINDING.getName(), binding);
            connectors.put(connectorName, new TransportConfiguration(NettyConnectorFactory.class.getName(), parameters, connectorName));
        }
    }
    if (params.hasDefined(IN_VM_CONNECTOR)) {
        for (final Property property : params.get(IN_VM_CONNECTOR).asPropertyList()) {
            final String connectorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
            parameters.put(CONNECTORS_KEYS_MAP.get(InVMTransportDefinition.SERVER_ID.getName()), InVMTransportDefinition.SERVER_ID.resolveModelAttribute(context, config).asInt());
            connectors.put(connectorName, new TransportConfiguration(InVMConnectorFactory.class.getName(), parameters, connectorName));
        }
    }
    if (params.hasDefined(HTTP_CONNECTOR)) {
        for (final Property property : params.get(HTTP_CONNECTOR).asPropertyList()) {
            final String connectorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
            final String binding = HTTPConnectorDefinition.SOCKET_BINDING.resolveModelAttribute(context, config).asString();
            bindings.add(binding);
            // ARTEMIS-803 Artemis knows that is must not offset the HTTP port when it is used by colocated backups
            parameters.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, true);
            parameters.put(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, HTTPConnectorDefinition.ENDPOINT.resolveModelAttribute(context, config).asString());
            // uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
            parameters.put(HTTPConnectorDefinition.SOCKET_BINDING.getName(), binding);
            ModelNode serverNameModelNode = HTTPConnectorDefinition.SERVER_NAME.resolveModelAttribute(context, config);
            // use the name of this server if the server-name attribute is undefined
            String serverName = serverNameModelNode.isDefined() ? serverNameModelNode.asString() : configuration.getName();
            parameters.put(ACTIVEMQ_SERVER_NAME, serverName);
            connectors.put(connectorName, new TransportConfiguration(NettyConnectorFactory.class.getName(), parameters, connectorName));
        }
    }
    configuration.setConnectorConfigurations(connectors);
}
Also used : HashMap(java.util.HashMap) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 12 with TransportConfiguration

use of org.apache.activemq.artemis.api.core.TransportConfiguration in project wildfly by wildfly.

the class TransportConfigOperationHandlers method processAcceptors.

/**
     * Process the acceptor information.
     *
     * @param context       the operation context
     * @param configuration the ActiveMQ configuration
     * @param params        the detyped operation parameters
     * @param bindings      the referenced socket bindings
     * @throws OperationFailedException
     */
static void processAcceptors(final OperationContext context, final Configuration configuration, final ModelNode params, final Set<String> bindings) throws OperationFailedException {
    final Map<String, TransportConfiguration> acceptors = new HashMap<String, TransportConfiguration>();
    if (params.hasDefined(ACCEPTOR)) {
        for (final Property property : params.get(ACCEPTOR).asPropertyList()) {
            final String acceptorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_KEYS_MAP);
            final String clazz = config.get(FACTORY_CLASS.getName()).asString();
            ModelNode socketBinding = GenericTransportDefinition.SOCKET_BINDING.resolveModelAttribute(context, config);
            if (socketBinding.isDefined()) {
                bindings.add(socketBinding.asString());
                // uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
                parameters.put(GenericTransportDefinition.SOCKET_BINDING.getName(), socketBinding.asString());
            }
            acceptors.put(acceptorName, new TransportConfiguration(clazz, parameters, acceptorName));
        }
    }
    if (params.hasDefined(REMOTE_ACCEPTOR)) {
        for (final Property property : params.get(REMOTE_ACCEPTOR).asPropertyList()) {
            final String acceptorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_KEYS_MAP);
            final String binding = config.get(RemoteTransportDefinition.SOCKET_BINDING.getName()).asString();
            bindings.add(binding);
            // uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
            parameters.put(RemoteTransportDefinition.SOCKET_BINDING.getName(), binding);
            acceptors.put(acceptorName, new TransportConfiguration(NettyAcceptorFactory.class.getName(), parameters, acceptorName));
        }
    }
    if (params.hasDefined(IN_VM_ACCEPTOR)) {
        for (final Property property : params.get(IN_VM_ACCEPTOR).asPropertyList()) {
            final String acceptorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_KEYS_MAP);
            parameters.put(SERVER_ID_PROP_NAME, InVMTransportDefinition.SERVER_ID.resolveModelAttribute(context, config).asInt());
            acceptors.put(acceptorName, new TransportConfiguration(InVMAcceptorFactory.class.getName(), parameters, acceptorName));
        }
    }
    if (params.hasDefined(HTTP_ACCEPTOR)) {
        for (final Property property : params.get(HTTP_ACCEPTOR).asPropertyList()) {
            final String acceptorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_KEYS_MAP);
            parameters.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, true);
            acceptors.put(acceptorName, new TransportConfiguration(NettyAcceptorFactory.class.getName(), parameters, acceptorName));
        }
    }
    configuration.setAcceptorConfigurations(new HashSet<TransportConfiguration>(acceptors.values()));
}
Also used : HashMap(java.util.HashMap) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 13 with TransportConfiguration

use of org.apache.activemq.artemis.api.core.TransportConfiguration in project wildfly by wildfly.

the class MessagingClientTestCase method createClientSessionFactory.

static ClientSessionFactory createClientSessionFactory(String host, int port, boolean httpUpgradeEnabled) throws Exception {
    final Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(TransportConstants.HOST_PROP_NAME, host);
    properties.put(TransportConstants.PORT_PROP_NAME, port);
    properties.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, httpUpgradeEnabled);
    if (httpUpgradeEnabled) {
        properties.put(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, "http-acceptor");
    }
    final TransportConfiguration configuration = new TransportConfiguration(NettyConnectorFactory.class.getName(), properties);
    return ActiveMQClient.createServerLocatorWithoutHA(configuration).createSessionFactory();
}
Also used : NettyConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory) HashMap(java.util.HashMap) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 14 with TransportConfiguration

use of org.apache.activemq.artemis.api.core.TransportConfiguration in project wildfly by wildfly.

the class SecurityTestCase method createClientSessionFactory.

static ClientSessionFactory createClientSessionFactory(String host, int port) throws Exception {
    final Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("host", host);
    properties.put("port", port);
    properties.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, true);
    properties.put(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, "http-acceptor");
    final TransportConfiguration configuration = new TransportConfiguration(NettyConnectorFactory.class.getName(), properties);
    return ActiveMQClient.createServerLocatorWithoutHA(configuration).createSessionFactory();
}
Also used : NettyConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory) HashMap(java.util.HashMap) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration)

Example 15 with TransportConfiguration

use of org.apache.activemq.artemis.api.core.TransportConfiguration in project wildfly by wildfly.

the class CoreQueueManagementTestCase method setup.

@Before
public void setup() throws Exception {
    count++;
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("host", TestSuiteEnvironment.getServerAddress());
    map.put("port", 8080);
    map.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, true);
    map.put(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, "http-acceptor");
    TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), map);
    ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(transportConfiguration);
    locator.setBlockOnDurableSend(true);
    locator.setBlockOnNonDurableSend(true);
    sessionFactory = locator.createSessionFactory();
    session = sessionFactory.createSession("guest", "guest", false, true, true, false, 1);
    session.createQueue(getQueueName(), getQueueName(), false);
    session.createQueue(getOtherQueueName(), getOtherQueueName(), false);
    consumerSession = sessionFactory.createSession("guest", "guest", false, false, false, false, 1);
}
Also used : NettyConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory) HashMap(java.util.HashMap) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Before(org.junit.Before)

Aggregations

TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)16 HashMap (java.util.HashMap)9 NettyConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory)5 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)3 InVMConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory)3 ModelNode (org.jboss.dmr.ModelNode)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)2 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)2 ConfigurationImpl (org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)2 Property (org.jboss.dmr.Property)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InetSocketAddress (java.net.InetSocketAddress)1 DataSource (javax.sql.DataSource)1 BroadcastEndpointFactory (org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)1 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)1 ChannelBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory)1