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