diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java index d2aa15d30a..78bbd531ac 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java @@ -52,9 +52,9 @@ public abstract class Configurable extends ActionAbstract { protected void treatError(Exception e, String group, String command) { logger.debug(e.getMessage(), e); - System.err.println(); - System.err.println("Error:" + e.getMessage()); - System.err.println(); + getActionContext().err.println(); + getActionContext().err.println("Error:" + e.getMessage()); + getActionContext().err.println(); if (!(e instanceof ActiveMQException)) { e.printStackTrace(); diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Connect.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Connect.java index 5ff144f78a..d3e7eff5dd 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Connect.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Connect.java @@ -29,9 +29,9 @@ public class Connect extends ConnectionAbstract { try { CONNECTION_INFORMATION.remove(); createConnectionFactory(); - System.out.println("Connection Successful!"); + context.out.println("Connection Successful!"); } catch (Exception e) { - System.out.println("Connection Failure!"); + context.out.println("Connection Failure!"); e.printStackTrace(); } return null; diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java index 431bf8a495..eab174ccab 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java @@ -994,7 +994,7 @@ public class Create extends InstallAbstract { RoutingType.valueOf(routingType.toUpperCase()); } catch (Exception e) { e.printStackTrace(); - System.err.println("Invalid routing type: " + routingType); + getActionContext().err.println("Invalid routing type: " + routingType); } printWriter.println("
"); printWriter.println(" <" + routingType + ">"); @@ -1011,7 +1011,7 @@ public class Create extends InstallAbstract { RoutingType.valueOf(routingType.toUpperCase()); } catch (Exception e) { e.printStackTrace(); - System.err.println("Invalid routing type: " + routingType); + getActionContext().err.println("Invalid routing type: " + routingType); } printWriter.println(" "); printWriter.println(" <" + routingType + "/>"); @@ -1042,8 +1042,8 @@ public class Create extends InstallAbstract { filters.put("${page-sync.settings}", readTextFile(ETC_PAGE_SYNC_SETTINGS, syncFilter)); } else { - long time = SyncCalculation.syncTest(dataFolder, 4096, writes, 5, verbose, !noJournalSync, false, "journal-test.tmp", ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio(), journalType); - long nanoseconds = SyncCalculation.toNanos(time, writes, verbose); + long time = SyncCalculation.syncTest(dataFolder, 4096, writes, 5, verbose, !noJournalSync, false, "journal-test.tmp", ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio(), journalType, getActionContext()); + long nanoseconds = SyncCalculation.toNanos(time, writes, verbose, getActionContext()); double writesPerMillisecond = (double) writes / (double) time; String writesPerMillisecondStr = new DecimalFormat("###.##").format(writesPerMillisecond); @@ -1061,8 +1061,8 @@ public class Create extends InstallAbstract { if (noJournalSync) { syncFilter.put("${nanoseconds}", "0"); } else if (journalType != JournalType.NIO) { - long nioTime = SyncCalculation.syncTest(dataFolder, 4096, writes, 5, verbose, !noJournalSync, false, "journal-test.tmp", ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio(), JournalType.NIO); - long nioNanoseconds = SyncCalculation.toNanos(nioTime, writes, verbose); + long nioTime = SyncCalculation.syncTest(dataFolder, 4096, writes, 5, verbose, !noJournalSync, false, "journal-test.tmp", ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio(), JournalType.NIO, getActionContext()); + long nioNanoseconds = SyncCalculation.toNanos(nioTime, writes, verbose, getActionContext()); syncFilter.put("${nanoseconds}", Long.toString(nioNanoseconds)); } @@ -1075,7 +1075,7 @@ public class Create extends InstallAbstract { filters.put("${journal-buffer.settings}", ""); filters.put("${page-sync.settings}", ""); e.printStackTrace(); - System.err.println("Couldn't perform sync calculation, using default values"); + getActionContext().err.println("Couldn't perform sync calculation, using default values"); } } } @@ -1096,7 +1096,7 @@ public class Create extends InstallAbstract { } tmpFile.delete(); if (!supportsLibaio) { - System.err.println("The filesystem used on " + directory + " doesn't support libAIO and O_DIRECT files, switching journal-type to NIO"); + getActionContext().err.println("The filesystem used on " + directory + " doesn't support libAIO and O_DIRECT files, switching journal-type to NIO"); } return supportsLibaio; } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Disconnect.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Disconnect.java index 4d05496b4c..8423e78da9 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Disconnect.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Disconnect.java @@ -27,7 +27,7 @@ public class Disconnect extends ConnectionAbstract { public Object execute(ActionContext context) throws Exception { super.execute(context); CONNECTION_INFORMATION.remove(); - System.out.println("Connection information cleared!"); + context.out.println("Connection information cleared!"); return null; } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/PWD.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/PWD.java index 29ec8a7172..74e25faae7 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/PWD.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/PWD.java @@ -26,16 +26,16 @@ public class PWD extends ActionAbstract { public Object execute(ActionContext context) throws Exception { super.execute(context); - System.out.println(); - System.out.println("*******************************************************************************************************************************"); - System.out.println("* Artemis instance:: " + getBrokerInstance()); - System.out.println("* Home:: " + getBrokerHome()); - System.out.println("* etc:: " + getBrokerEtc()); + context.out.println(); + context.out.println("*******************************************************************************************************************************"); + context.out.println("* Artemis instance:: " + getBrokerInstance()); + context.out.println("* Home:: " + getBrokerHome()); + context.out.println("* etc:: " + getBrokerEtc()); String canonicalPath = new java.io.File(".").getCanonicalPath(); - System.out.println("* Current dir:" + canonicalPath); - System.out.println("*******************************************************************************************************************************"); - System.out.println(); + context.out.println("* Current dir:" + canonicalPath); + context.out.println("*******************************************************************************************************************************"); + context.out.println(); return null; } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java index c032d69bc5..e5200a9727 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java @@ -195,7 +195,7 @@ public class Run extends LockAbstract { public void run() { if (allowKill && fileKill.exists()) { try { - System.err.println("Halting by user request"); + getActionContext().err.println("Halting by user request"); fileKill.delete(); } catch (Throwable ignored) { } @@ -243,15 +243,15 @@ public class Run extends LockAbstract { } - public static void verifyOlderLogging(File etc) throws Exception { + public void verifyOlderLogging(File etc) { File newLogging = new File(etc, Create.ETC_LOG4J2_PROPERTIES); File oldLogging = new File(etc, Upgrade.OLD_LOGGING_PROPERTIES); if (oldLogging.exists() && !newLogging.exists()) { - System.out.println("******************************************************************************************************************************************************************************"); - System.out.println("Your system has the older logging file " + Upgrade.OLD_LOGGING_PROPERTIES + ", but not the new " + Create.ETC_LOG4J2_PROPERTIES); - System.out.println("It appears you did not complete the migration on this artemis instance properly. Please check all the settings or run the './artemis upgrade' command from the new artemis home"); - System.out.println("******************************************************************************************************************************************************************************"); + getActionContext().out.println("******************************************************************************************************************************************************************************"); + getActionContext().out.println("Your system has the older logging file " + Upgrade.OLD_LOGGING_PROPERTIES + ", but not the new " + Create.ETC_LOG4J2_PROPERTIES); + getActionContext().out.println("It appears you did not complete the migration on this artemis instance properly. Please check all the settings or run the './artemis upgrade' command from the new artemis home"); + getActionContext().out.println("******************************************************************************************************************************************************************************"); } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java index c133ed7d89..fdc3ba8ae7 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java @@ -50,7 +50,7 @@ public class Browse extends DestAbstract { session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } Destination dest = getDestination(session); - threadsArray[i] = new ConsumerThread(session, dest, i); + threadsArray[i] = new ConsumerThread(session, dest, i, context); threadsArray[i] .setVerbose(verbose) diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConnectionAbstract.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConnectionAbstract.java index 52422f5993..ceabc5b825 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConnectionAbstract.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConnectionAbstract.java @@ -234,7 +234,7 @@ public class ConnectionAbstract extends InputAbstract { void saveConnectionInfo(String brokerURL, String user, String password) { if (Shell.inShell() && CONNECTION_INFORMATION.get() == null) { CONNECTION_INFORMATION.set(new ConnectionInformation(brokerURL, user, password)); - System.out.println("CLI connected to broker " + brokerURL + ", user:" + user); + getActionContext().out.println("CLI connected to broker " + brokerURL + ", user:" + user); this.brokerURL = brokerURL; this.user = user; this.password = password; diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java index a14a820c9c..9140da987a 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java @@ -63,14 +63,14 @@ public class Consumer extends DestAbstract { if (file != null) { serializer = getMessageSerializer(); if (serializer == null) { - System.err.println("Error. Unable to instantiate serializer class: " + this.serializer); + context.err.println("Error. Unable to instantiate serializer class: " + this.serializer); return null; } try { outputStream = new BufferedOutputStream(new FileOutputStream(file)); } catch (Exception e) { - System.err.println("Error: Unable to open file for writing\n" + e.getMessage()); + context.err.println("Error: Unable to open file for writing\n" + e.getMessage()); return null; } @@ -92,7 +92,7 @@ public class Consumer extends DestAbstract { } Destination dest = getDestination(session); - threadsArray[i] = new ConsumerThread(session, dest, i); + threadsArray[i] = new ConsumerThread(session, dest, i, context); threadsArray[i] .setVerbose(verbose) diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConsumerThread.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConsumerThread.java index f2bee77ba4..6c9424db2f 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConsumerThread.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConsumerThread.java @@ -31,12 +31,15 @@ import javax.jms.Topic; import java.util.Enumeration; import java.util.concurrent.CountDownLatch; +import org.apache.activemq.artemis.cli.commands.ActionContext; + public class ConsumerThread extends Thread { long messageCount = 1000; int receiveTimeOut = 3000; Destination destination; Session session; + ActionContext context; boolean durable; boolean breakOnNull = true; int sleep; @@ -53,10 +56,11 @@ public class ConsumerThread extends Thread { boolean bytesAsText; MessageListener listener; - public ConsumerThread(Session session, Destination destination, int threadNr) { + public ConsumerThread(Session session, Destination destination, int threadNr, ActionContext context) { super("Consumer " + destination.toString() + ", thread=" + threadNr); this.destination = destination; this.session = session; + this.context = context; } @Override @@ -74,32 +78,32 @@ public class ConsumerThread extends Thread { } else { if (browse) { if (verbose) { - System.out.println("..." + msg); + context.out.println("..." + msg); } if (bytesAsText && (msg instanceof BytesMessage)) { long length = ((BytesMessage) msg).getBodyLength(); byte[] bytes = new byte[(int) length]; ((BytesMessage) msg).readBytes(bytes); - System.out.println("Message:" + msg); + context.out.println("Message:" + msg); } } else { if (verbose) { - System.out.println("JMS Message ID:" + msg.getJMSMessageID()); + context.out.println("JMS Message ID:" + msg.getJMSMessageID()); if (bytesAsText && (msg instanceof BytesMessage)) { long length = ((BytesMessage) msg).getBodyLength(); byte[] bytes = new byte[(int) length]; ((BytesMessage) msg).readBytes(bytes); - System.out.println("Received a message with " + bytes.length); + context.out.println("Received a message with " + bytes.length); } if (msg instanceof TextMessage) { String text = ((TextMessage) msg).getText(); - System.out.println("Received text sized at " + text.length()); + context.out.println("Received text sized at " + text.length()); } if (msg instanceof ObjectMessage) { Object obj = ((ObjectMessage) msg).getObject(); - System.out.println("Received object " + obj.toString().length()); + context.out.println("Received object " + obj.toString().length()); } } } @@ -110,7 +114,7 @@ public class ConsumerThread extends Thread { running = true; QueueBrowser consumer = null; String threadName = Thread.currentThread().getName(); - System.out.println(threadName + " trying to browse " + messageCount + " messages"); + context.out.println(threadName + " trying to browse " + messageCount + " messages"); try { if (filter != null) { consumer = session.createBrowser((Queue) destination, filter); @@ -122,7 +126,7 @@ public class ConsumerThread extends Thread { while (enumBrowse.hasMoreElements()) { Message msg = enumBrowse.nextElement(); if (msg != null) { - System.out.println(threadName + " browsing " + (msg instanceof TextMessage ? ((TextMessage) msg).getText() : msg.getJMSMessageID())); + context.out.println(threadName + " browsing " + (msg instanceof TextMessage ? ((TextMessage) msg).getText() : msg.getJMSMessageID())); handle(msg, true); received++; @@ -147,7 +151,7 @@ public class ConsumerThread extends Thread { finished.countDown(); } if (consumer != null) { - System.out.println(threadName + " browsed: " + this.getReceived() + " messages"); + context.out.println(threadName + " browsed: " + this.getReceived() + " messages"); try { consumer.close(); } catch (JMSException e) { @@ -156,14 +160,14 @@ public class ConsumerThread extends Thread { } } - System.out.println(threadName + " Browser thread finished"); + context.out.println(threadName + " Browser thread finished"); } public void consume() { running = true; MessageConsumer consumer = null; String threadName = Thread.currentThread().getName(); - System.out.println(threadName + " wait until " + messageCount + " messages are consumed"); + context.out.println(threadName + " wait until " + messageCount + " messages are consumed"); try { if (durable && destination instanceof Topic) { if (filter != null) { @@ -184,10 +188,10 @@ public class ConsumerThread extends Thread { Message msg = consumer.receive(receiveTimeOut); if (msg != null) { if (verbose) { - System.out.println(threadName + " Received " + (msg instanceof TextMessage ? ((TextMessage) msg).getText() : msg.getJMSMessageID())); + context.out.println(threadName + " Received " + (msg instanceof TextMessage ? ((TextMessage) msg).getText() : msg.getJMSMessageID())); } else { if (++count % 1000 == 0) { - System.out.println("Received " + count); + context.out.println("Received " + count); } } handle(msg, false); @@ -200,12 +204,12 @@ public class ConsumerThread extends Thread { if (session.getTransacted()) { if (batchSize > 0 && received > 0 && received % batchSize == 0) { - System.out.println(threadName + " Committing transaction: " + transactions++); + context.out.println(threadName + " Committing transaction: " + transactions++); session.commit(); } } else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE && msg != null) { if (batchSize > 0 && received > 0 && received % batchSize == 0) { - System.out.println("Acknowledging last " + batchSize + " messages; messages so far = " + received); + context.out.println("Acknowledging last " + batchSize + " messages; messages so far = " + received); msg.acknowledge(); } } @@ -221,11 +225,11 @@ public class ConsumerThread extends Thread { } - System.out.println(threadName + " Consumed: " + this.getMessageCount() + " messages"); + context.out.println(threadName + " Consumed: " + this.getMessageCount() + " messages"); long tEnd = System.currentTimeMillis(); long elapsed = (tEnd - tStart) / 1000; - System.out.println(threadName + " Elapsed time in second : " + elapsed + " s"); - System.out.println(threadName + " Elapsed time in milli second : " + (tEnd - tStart) + " milli seconds"); + context.out.println(threadName + " Elapsed time in second : " + elapsed + " s"); + context.out.println(threadName + " Elapsed time in milli second : " + (tEnd - tStart) + " milli seconds"); } catch (Exception e) { e.printStackTrace(); @@ -234,7 +238,7 @@ public class ConsumerThread extends Thread { finished.countDown(); } if (consumer != null) { - System.out.println(threadName + " Consumed: " + this.getReceived() + " messages"); + context.out.println(threadName + " Consumed: " + this.getReceived() + " messages"); try { consumer.close(); } catch (JMSException e) { @@ -243,7 +247,7 @@ public class ConsumerThread extends Thread { } } - System.out.println(threadName + " Consumer thread finished"); + context.out.println(threadName + " Consumer thread finished"); } public int getReceived() { diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/DestAbstract.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/DestAbstract.java index a23a22c1db..88c87c28f0 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/DestAbstract.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/DestAbstract.java @@ -55,13 +55,13 @@ public class DestAbstract extends ConnectionAbstract { try { return (MessageSerializer) Class.forName(serializer).getConstructor().newInstance(); } catch (Exception e) { - System.err.println("Error: unable to instantiate serializer class: " + serializer); - System.err.println("Defaulting to: " + XMLMessageSerializer.class.getName()); + getActionContext().err.println("Error: unable to instantiate serializer class: " + serializer); + getActionContext().err.println("Defaulting to: " + XMLMessageSerializer.class.getName()); } } if (protocol != ConnectionProtocol.CORE) { - System.err.println("Default Serializer does not support: " + protocol + " protocol"); + getActionContext().err.println("Default Serializer does not support: " + protocol + " protocol"); return null; } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java index 20235f7e0c..38870b09c6 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java @@ -153,7 +153,7 @@ public class Producer extends DestAbstract { try { MessageSerializer serializer = getMessageSerializer(); if (serializer == null) { - System.err.println("Error. Unable to instantiate serializer class: " + serializer); + context.err.println("Error. Unable to instantiate serializer class: " + serializer); return null; } @@ -161,7 +161,7 @@ public class Producer extends DestAbstract { try { in = new FileInputStream(file); } catch (Exception e) { - System.err.println("Error: Unable to open file for reading\n" + e.getMessage()); + context.err.println("Error: Unable to open file for reading\n" + e.getMessage()); return null; } @@ -179,12 +179,12 @@ public class Producer extends DestAbstract { session.commit(); serializer.stop(); } catch (Exception e) { - System.err.println("Error occurred during import. Rolling back."); + context.err.println("Error occurred during import. Rolling back."); session.rollback(); e.printStackTrace(); return 0; } - System.out.println("Sent " + messageCount + " Messages."); + context.out.println("Sent " + messageCount + " Messages."); return messageCount; } else { ProducerThread[] threadsArray = new ProducerThread[threads]; @@ -196,7 +196,7 @@ public class Producer extends DestAbstract { session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } Destination dest = getDestination(session); - threadsArray[i] = new ProducerThread(session, dest, i); + threadsArray[i] = new ProducerThread(session, dest, i, context); threadsArray[i] .setVerbose(verbose) diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ProducerThread.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ProducerThread.java index efff71af67..a624366fe3 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ProducerThread.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ProducerThread.java @@ -30,11 +30,13 @@ import java.io.InputStreamReader; import java.net.URL; import java.util.concurrent.atomic.AtomicLong; +import org.apache.activemq.artemis.cli.commands.ActionContext; import org.apache.activemq.artemis.utils.ReusableLatch; public class ProducerThread extends Thread { protected final Session session; + protected final ActionContext context; boolean verbose; long messageCount = 1000; @@ -59,10 +61,11 @@ public class ProducerThread extends Thread { final ReusableLatch finished = new ReusableLatch(1); final ReusableLatch paused = new ReusableLatch(0); - public ProducerThread(Session session, Destination destination, int threadNr) { + public ProducerThread(Session session, Destination destination, int threadNr, ActionContext context) { super("Producer " + destination.toString() + ", thread=" + threadNr); this.destination = destination; this.session = session; + this.context = context; } @Override @@ -76,7 +79,7 @@ public class ProducerThread extends Thread { initPayLoad(); running = true; - System.out.println(threadName + " Started to calculate elapsed time ...\n"); + context.out.println(threadName + " Started to calculate elapsed time ...\n"); long tStart = System.currentTimeMillis(); if (runIndefinitely) { @@ -97,11 +100,11 @@ public class ProducerThread extends Thread { } catch (Throwable ignored) { } - System.out.println(threadName + " Produced: " + this.getSentCount() + " messages"); + context.out.println(threadName + " Produced: " + this.getSentCount() + " messages"); long tEnd = System.currentTimeMillis(); long elapsed = (tEnd - tStart) / 1000; - System.out.println(threadName + " Elapsed time in second : " + elapsed + " s"); - System.out.println(threadName + " Elapsed time in milli second : " + (tEnd - tStart) + " milli seconds"); + context.out.println(threadName + " Elapsed time in second : " + elapsed + " s"); + context.out.println(threadName + " Elapsed time in milli second : " + (tEnd - tStart) + " milli seconds"); } catch (Exception e) { e.printStackTrace(); @@ -124,11 +127,11 @@ public class ProducerThread extends Thread { producer.send(message); if (verbose) { - System.out.println(threadName + " Sent: " + (message instanceof TextMessage ? ((TextMessage) message).getText() : message.getJMSMessageID())); + context.out.println(threadName + " Sent: " + (message instanceof TextMessage ? ((TextMessage) message).getText() : message.getJMSMessageID())); } if (transactionBatchSize > 0 && sentCount.get() > 0 && sentCount.get() % transactionBatchSize == 0) { - System.out.println(threadName + " Committing transaction: " + transactions++); + context.out.println(threadName + " Committing transaction: " + transactions++); session.commit(); } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Transfer.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Transfer.java index abb1bf6e2a..ed6f6e4260 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Transfer.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Transfer.java @@ -335,7 +335,7 @@ public class Transfer extends InputAbstract { } } - System.out.println("Connection brokerURL = " + sourceURL); + context.out.println("Connection brokerURL = " + sourceURL); ConnectionFactory sourceConnectionFactory = createConnectionFactory("source", sourceProtocol, sourceURL, sourceUser, sourcePassword, sourceClientID); Connection sourceConnection = sourceConnectionFactory.createConnection(); @@ -383,7 +383,7 @@ public class Transfer extends InputAbstract { MessageProducer producer = targetSession.createProducer(targetDestination); if (sourceURL.equals(targetURL) && sourceDestination.equals(targetDestination)) { - System.out.println("You cannot transfer between " + sourceURL + "/" + sourceDestination + " and " + targetURL + "/" + targetDestination + ".\n" + "That would create an infinite recursion."); + context.out.println("You cannot transfer between " + sourceURL + "/" + sourceDestination + " and " + targetURL + "/" + targetDestination + ".\n" + "That would create an infinite recursion."); throw new IllegalArgumentException("cannot use " + sourceDestination + " == " + targetDestination); } @@ -402,7 +402,7 @@ public class Transfer extends InputAbstract { if (receivedMessage == null) { if (isVerbose()) { - System.out.println("could not receive any more messages"); + context.out.println("could not receive any more messages"); } break; } @@ -411,10 +411,10 @@ public class Transfer extends InputAbstract { total++; if (isVerbose()) { - System.out.println("Received message " + total + " with " + pending + " messages pending to be commited"); + context.out.println("Received message " + total + " with " + pending + " messages pending to be commited"); } if (pending > commitInterval) { - System.out.println("Transferred " + pending + " messages of " + total); + context.out.println("Transferred " + pending + " messages of " + total); pending = 0; targetSession.commit(); if (!isCopy()) { @@ -423,7 +423,7 @@ public class Transfer extends InputAbstract { } } - System.out.println("Transferred a total of " + total + " messages"); + context.out.println("Transferred a total of " + total + " messages"); if (pending != 0) { targetSession.commit(); @@ -464,12 +464,12 @@ public class Transfer extends InputAbstract { String clientID) throws Exception { if (protocol.equals("core")) { if (isVerbose()) { - System.out.println("Creating " + role + " CORE Connection towards " + brokerURL); + getActionContext().out.println("Creating " + role + " CORE Connection towards " + brokerURL); } return createCoreConnectionFactory(brokerURL, user, password, clientID); } else if (protocol.equals("amqp")) { if (isVerbose()) { - System.out.println("Creating " + role + " AMQP Connection towards " + brokerURL); + getActionContext().out.println("Creating " + role + " AMQP Connection towards " + brokerURL); } return createAMQPConnectionFactory(brokerURL, user, password, clientID); } else { @@ -523,7 +523,7 @@ public class Transfer extends InputAbstract { ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(brokerURL, user, password); if (clientID != null) { - System.out.println("Consumer:: clientID = " + clientID); + getActionContext().out.println("Consumer:: clientID = " + clientID); cf.setClientID(clientID); } try { @@ -553,7 +553,7 @@ public class Transfer extends InputAbstract { } Pair