Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4CE309315 for ; Tue, 5 Jun 2012 20:15:16 +0000 (UTC) Received: (qmail 78750 invoked by uid 500); 5 Jun 2012 20:15:16 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 78678 invoked by uid 500); 5 Jun 2012 20:15:16 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 78671 invoked by uid 99); 5 Jun 2012 20:15:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jun 2012 20:15:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jun 2012 20:15:13 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 379A02388860 for ; Tue, 5 Jun 2012 20:14:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1346567 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src: main/csharp/Commands/ActiveMQObjectMessage.cs test/csharp/Commands/MessageCompressionTest.cs Date: Tue, 05 Jun 2012 20:14:52 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120605201452.379A02388860@eris.apache.org> Author: tabish Date: Tue Jun 5 20:14:51 2012 New Revision: 1346567 URL: http://svn.apache.org/viewvc?rev=1346567&view=rev Log: fix for: https://issues.apache.org/jira/browse/AMQNET-388 Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/Commands/ActiveMQObjectMessage.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/test/csharp/Commands/MessageCompressionTest.cs Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/Commands/ActiveMQObjectMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/Commands/ActiveMQObjectMessage.cs?rev=1346567&r1=1346566&r2=1346567&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/Commands/ActiveMQObjectMessage.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/main/csharp/Commands/ActiveMQObjectMessage.cs Tue Jun 5 20:14:51 2012 @@ -18,6 +18,7 @@ using System.IO; #if !(PocketPC||NETCF||NETCF_2_0) +using Apache.NMS.Util; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; #endif @@ -61,8 +62,21 @@ namespace Apache.NMS.ActiveMQ.Commands { #if !(PocketPC||NETCF||NETCF_2_0) if (body == null) - { - body = Formatter.Deserialize(new MemoryStream(Content)); + { + if(base.Content == null) + { + return null; + } + + byte[] data = base.Content; + Stream target = new MemoryStream(data, false); + + if(this.Connection != null && this.Compressed == true) + { + target = this.Connection.CompressionPolicy.CreateDecompressionStream(target); + } + + body = Formatter.Deserialize(target); } return body; #else @@ -89,9 +103,17 @@ namespace Apache.NMS.ActiveMQ.Commands } else { - MemoryStream stream = new MemoryStream(); - Formatter.Serialize(stream, body); - Content = stream.ToArray(); + MemoryStream result = new MemoryStream(); + Stream target = result; + if(this.Connection != null && this.Connection.UseCompression) + { + this.Compressed = true; + target = this.Connection.CompressionPolicy.CreateCompressionStream(target); + } + + Formatter.Serialize(target, body); + target.Close(); + Content = result.ToArray(); } //Console.WriteLine("BeforeMarshalling, content is: " + Content); Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/test/csharp/Commands/MessageCompressionTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/test/csharp/Commands/MessageCompressionTest.cs?rev=1346567&r1=1346566&r2=1346567&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/test/csharp/Commands/MessageCompressionTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x/src/test/csharp/Commands/MessageCompressionTest.cs Tue Jun 5 20:14:51 2012 @@ -17,6 +17,7 @@ using System; using System.IO; +using Apache.NMS; using Apache.NMS.Test; using Apache.NMS.ActiveMQ.Commands; using NUnit.Framework; @@ -86,6 +87,36 @@ namespace Apache.NMS.ActiveMQ.Test } [Test] + public void TestObjectMessageCompression() + { + using(Connection connection = CreateConnection(TEST_CLIENT_ID) as Connection) + { + connection.UseCompression = true; + connection.Start(); + + Assert.IsTrue(connection.UseCompression); + + using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) + { + IObjectMessage message = session.CreateObjectMessage(TEXT); + + IDestination destination = session.CreateTemporaryQueue(); + + IMessageProducer producer = session.CreateProducer(destination); + IMessageConsumer consumer = session.CreateConsumer(destination); + + producer.Send(message); + + message = consumer.Receive(TimeSpan.FromMilliseconds(6000)) as IObjectMessage; + + Assert.IsNotNull(message); + Assert.IsTrue(((ActiveMQMessage) message).Compressed); + Assert.AreEqual(TEXT, message.Body); + } + } + } + + [Test] public void TestStreamMessageCompression() { using(Connection connection = CreateConnection(TEST_CLIENT_ID) as Connection)