Search in sources :

Example 1 with ServerLocator

use of org.apache.activemq.artemis.api.core.client.ServerLocator in project spring-boot by spring-projects.

the class ArtemisConnectionFactoryFactory method createEmbeddedConnectionFactory.

private <T extends ActiveMQConnectionFactory> T createEmbeddedConnectionFactory(Class<T> factoryClass) throws Exception {
    try {
        TransportConfiguration transportConfiguration = new TransportConfiguration(InVMConnectorFactory.class.getName(), this.properties.getEmbedded().generateTransportParameters());
        ServerLocator serviceLocator = ActiveMQClient.createServerLocatorWithoutHA(transportConfiguration);
        return factoryClass.getConstructor(ServerLocator.class).newInstance(serviceLocator);
    } catch (NoClassDefFoundError ex) {
        throw new IllegalStateException("Unable to create InVM " + "Artemis connection, ensure that artemis-jms-server.jar " + "is in the classpath", ex);
    }
}
Also used : TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator)

Example 2 with ServerLocator

use of org.apache.activemq.artemis.api.core.client.ServerLocator 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)

Example 3 with ServerLocator

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

the class ImportJournalOperation method executeRuntimeStep.

@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
    if (context.getRunningMode() != NORMAL) {
        throw MessagingLogger.ROOT_LOGGER.managementOperationAllowedOnlyInRunningMode("import-journal", NORMAL);
    }
    String file = FILE.resolveModelAttribute(context, operation).asString();
    final XmlDataImporter importer = new XmlDataImporter();
    TransportConfiguration transportConfiguration = createInVMTransportConfiguration(context);
    try (InputStream is = new FileInputStream(new File(file));
        ServerLocator serverLocator = ActiveMQClient.createServerLocator(false, transportConfiguration);
        ClientSessionFactory sf = serverLocator.createSessionFactory()) {
        ClientSession session = sf.createSession();
        importer.process(is, session);
    } catch (Exception e) {
        throw new OperationFailedException(e);
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) OperationFailedException(org.jboss.as.controller.OperationFailedException) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) File(java.io.File) FileInputStream(java.io.FileInputStream) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) OperationFailedException(org.jboss.as.controller.OperationFailedException) XmlDataImporter(org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter)

Aggregations

TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)3 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)3 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)1 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)1 XmlDataImporter (org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter)1 InVMConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory)1 NettyConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 Before (org.junit.Before)1