Search in sources :

Example 1 with XmlDataImporter

use of org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter 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

File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)1 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)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