activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-620 clean up large messages
Date Mon, 11 Jul 2016 17:44:33 GMT
ARTEMIS-620 clean up large messages


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/59bfb33c
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/59bfb33c
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/59bfb33c

Branch: refs/heads/master
Commit: 59bfb33c2939ad3245ac2b9a26815f7dc3b9fb4e
Parents: 43596c2
Author: jbertram <jbertram@apache.org>
Authored: Mon Jul 11 09:46:08 2016 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Mon Jul 11 13:43:58 2016 -0400

----------------------------------------------------------------------
 examples/features/standard/large-message/pom.xml |  1 +
 .../artemis/jms/example/LargeMessageExample.java | 19 +++++++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59bfb33c/examples/features/standard/large-message/pom.xml
----------------------------------------------------------------------
diff --git a/examples/features/standard/large-message/pom.xml b/examples/features/standard/large-message/pom.xml
index 358c9f9..5a22537 100644
--- a/examples/features/standard/large-message/pom.xml
+++ b/examples/features/standard/large-message/pom.xml
@@ -69,6 +69,7 @@ under the License.
                      <clientClass>org.apache.activemq.artemis.jms.example.LargeMessageExample</clientClass>
                      <args>
                         <param>${basedir}/target/server0</param>
+                        <param>true</param> <!-- delete the large files sent
and received? -->
                      </args>
                   </configuration>
                </execution>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59bfb33c/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java
----------------------------------------------------------------------
diff --git a/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java
b/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java
index 8c600c9..b400d41 100644
--- a/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java
+++ b/examples/features/standard/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java
@@ -52,6 +52,9 @@ public class LargeMessageExample {
       Process server = null;
       Connection connection = null;
       InitialContext initialContext = null;
+      File inputFile = null;
+      File outputFile = null;
+      boolean deleteFiles = Boolean.parseBoolean(args[1]);
 
       try {
          server = ServerUtil.startServer(args[0], LargeMessageExample.class.getSimpleName(),
0, 5000);
@@ -80,9 +83,9 @@ public class LargeMessageExample {
                                " bytes. This may take a little while... " +
                                "If this is too big for your disk you can easily change the
FILE_SIZE in the example.");
 
-         File fileInput = new File("huge_message_to_send.dat");
+         inputFile = new File("huge_message_to_send.dat");
 
-         createFile(fileInput, FILE_SIZE);
+         createFile(inputFile, FILE_SIZE);
 
          System.out.println("File created.");
 
@@ -92,7 +95,7 @@ public class LargeMessageExample {
          // Step 7. We set the InputStream on the message. When sending the message will
read the InputStream
          // until it gets EOF. In this case we point the InputStream at a file on disk, and
it will suck up the entire
          // file, however we could use any InputStream not just a FileInputStream.
-         FileInputStream fileInputStream = new FileInputStream(fileInput);
+         FileInputStream fileInputStream = new FileInputStream(inputFile);
          BufferedInputStream bufferedInput = new BufferedInputStream(fileInputStream);
 
          message.setObjectProperty("JMS_AMQ_InputStream", bufferedInput);
@@ -153,7 +156,7 @@ public class LargeMessageExample {
          // You may choose to use the regular BytesMessage or
          // StreamMessage interface but this method is much faster for large messages.
 
-         File outputFile = new File("huge_message_received.dat");
+         outputFile = new File("huge_message_received.dat");
 
          try (FileOutputStream fileOutputStream = new FileOutputStream(outputFile)) {
             BufferedOutputStream bufferedOutput = new BufferedOutputStream(fileOutputStream);
@@ -174,6 +177,14 @@ public class LargeMessageExample {
             connection.close();
          }
 
+         if (inputFile != null && deleteFiles) {
+            inputFile.delete();
+         }
+
+         if (outputFile != null && deleteFiles) {
+            outputFile.delete();
+         }
+
          ServerUtil.killServer(server);
       }
    }


Mime
View raw message