Search in sources :

Example 6 with ClientSession

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

the class ArtemisMessagingTestCase method stop.

@After
public void stop() throws Exception {
    if (session != null) {
        session.close();
    }
    if (sf != null) {
        ClientSession coreSession = sf.createSession();
        coreSession.deleteQueue(QUEUE_EXAMPLE_QUEUE);
        coreSession.close();
        sf.close();
    }
}
Also used : ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) After(org.junit.After)

Example 7 with ClientSession

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

ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)7 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)4 Test (org.junit.Test)3 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)2 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Date (java.util.Date)1 IllegalStateException (javax.resource.spi.IllegalStateException)1 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)1 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)1 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)1 XmlDataImporter (org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)1 ModelNode (org.jboss.dmr.ModelNode)1 After (org.junit.After)1