activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1481527 - in /activemq/trunk: activemq-client/src/main/java/org/apache/activemq/command/ activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/
Date Sun, 12 May 2013 11:23:30 GMT
Author: chirino
Date: Sun May 12 11:23:30 2013
New Revision: 1481527

URL: http://svn.apache.org/r1481527
Log:
Add a storeConentAndClear() method to message so that we can lower the memory impact of embedded
broker usage.

Modified:
    activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
    activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
    activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java
    activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java
    activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/Message.java
    activemq/trunk/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/DBManager.scala

Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java?rev=1481527&r1=1481526&r2=1481527&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
(original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
Sun May 12 11:23:30 2013
@@ -136,6 +136,12 @@ public class ActiveMQMapMessage extends 
     }
 
     @Override
+    public void storeContentAndClear() {
+        storeContent();
+        map.clear();
+    }
+
+    @Override
     public void storeContent() {
         try {
             if (getContent() == null && !map.isEmpty()) {

Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMessage.java?rev=1481527&r1=1481526&r2=1481527&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
(original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
Sun May 12 11:23:30 2013
@@ -752,4 +752,9 @@ public class ActiveMQMessage extends Mes
     @Override
     public void storeContent() {
     }
+
+    @Override
+    public void storeContentAndClear() {
+        storeContent();
+    }
 }

Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java?rev=1481527&r1=1481526&r2=1481527&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java
(original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java
Sun May 12 11:23:30 2013
@@ -90,6 +90,12 @@ public class ActiveMQObjectMessage exten
     }
 
     @Override
+    public void storeContentAndClear() {
+        storeContent();
+        object = null;
+    }
+
+    @Override
     public void storeContent() {
         ByteSequence bodyAsBytes = getContent();
         if (bodyAsBytes == null && object != null) {

Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java?rev=1481527&r1=1481526&r2=1481527&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java
(original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java
Sun May 12 11:23:30 2013
@@ -74,6 +74,16 @@ public class ActiveMQTextMessage extends
 
     public String getText() throws JMSException {
         if (text == null && getContent() != null) {
+            text = decodeContent();
+            setContent(null);
+            setCompressed(false);
+        }
+        return text;
+    }
+
+    private String decodeContent() throws JMSException {
+        String text = null;
+        if (getContent() != null) {
             InputStream is = null;
             try {
                 ByteSequence bodyAsBytes = getContent();
@@ -85,8 +95,6 @@ public class ActiveMQTextMessage extends
                     DataInputStream dataIn = new DataInputStream(is);
                     text = MarshallingSupport.readUTF8(dataIn);
                     dataIn.close();
-                    setContent(null);
-                    setCompressed(false);
                 }
             } catch (IOException ioe) {
                 throw JMSExceptionSupport.create(ioe);
@@ -109,6 +117,12 @@ public class ActiveMQTextMessage extends
     }
 
     @Override
+    public void storeContentAndClear() {
+        storeContent();
+        text=null;
+    }
+
+    @Override
     public void storeContent() {
         try {
             ByteSequence content = getContent();
@@ -166,7 +180,10 @@ public class ActiveMQTextMessage extends
 
     public String toString() {
         try {
-            String text = getText();
+            String text = this.text;
+            if( text == null ) {
+                text = decodeContent();
+            }
             if (text != null) {
                 text = MarshallingSupport.truncate64(text);
                 HashMap<String, Object> overrideFields = new HashMap<String, Object>();

Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/Message.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/Message.java?rev=1481527&r1=1481526&r2=1481527&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/Message.java
(original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/Message.java
Sun May 12 11:23:30 2013
@@ -104,6 +104,7 @@ public abstract class Message extends Ba
     public abstract Message copy();
     public abstract void clearBody() throws JMSException;
     public abstract void storeContent();
+    public abstract void storeContentAndClear();
 
     // useful to reduce the memory footprint of a persisted message
     public void clearMarshalledState() throws JMSException {

Modified: activemq/trunk/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/DBManager.scala
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/DBManager.scala?rev=1481527&r1=1481526&r2=1481527&view=diff
==============================================================================
--- activemq/trunk/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/DBManager.scala
(original)
+++ activemq/trunk/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/DBManager.scala
Sun May 12 11:23:30 2013
@@ -257,6 +257,9 @@ class DelayableUOW(val manager:DBManager
 
     val messageRecord = id.getDataLocator match {
       case null =>
+        // encodes body and release object bodies, in case message was sent from
+        // a VM connection.  Releases additional memory.
+        message.storeContentAndClear()
         var packet = manager.parent.wireFormat.marshal(message)
         var data = new Buffer(packet.data, packet.offset, packet.length)
         if( manager.snappyCompressLogs ) {



Mime
View raw message