Author: timfox
Date: 2009-11-22 13:47:45 -0500 (Sun, 22 Nov 2009)
New Revision: 8367
Added:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java
Removed:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/FileLargeServerMessage.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/EncodeSizeTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/persistence/JournalStorageManagerIntegrationTest.java
Modified:
branches/20-optimisation/examples/core/perf/src/org/hornetq/core/example/PerfBase.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java
branches/20-optimisation/src/main/org/hornetq/core/message/Message.java
branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMapMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessageProducer.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQObjectMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSExpirationHeaderTest.java
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSMessageIDHeaderTest.java
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageBodyTest.java
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/String64KLimitTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AddressSettingsTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerRoundRobinTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeadLetterAddressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeliveryOrderTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ExpiryAddressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/HeuristicXATest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/JournalCrashTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageCounterTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageGroupingTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessagePriorityTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/QueueBrowserTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ReceiveImmediateTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SessionCreateProducerTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/WildCardRoutingTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientExitTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/GracefulClient.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/paging/PageCrashTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/security/SimpleClient.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/ExpiryRunnerTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQRecoveryTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaRecoveryTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/XaTimeoutTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/performance/paging/MeasurePagingMultiThreadTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/util/ServiceTestBase.java
branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
optimisation
Modified:
branches/20-optimisation/examples/core/perf/src/org/hornetq/core/example/PerfBase.java
===================================================================
---
branches/20-optimisation/examples/core/perf/src/org/hornetq/core/example/PerfBase.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/examples/core/perf/src/org/hornetq/core/example/PerfBase.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -355,7 +355,7 @@
byte[] payload = randomByteArray(messageSize);
- message.getBuffer().writeBytes(payload);
+ message.getBodyBuffer().writeBytes(payload);
final int modulo = 2000;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -454,7 +454,23 @@
public void writeBytes(final HornetQBuffer src, final int srcIndex, final int length)
{
- writeBytes((HornetQChannelBuffer)src, srcIndex, length);
+ if (src instanceof HornetQChannelBuffer)
+ {
+ writeBytes((HornetQChannelBuffer)src, srcIndex, length);
+ }
+ else
+ {
+ //There is a bug in Netty readBytes() which doesn't let us to do this, so we
workaround it
+// byte[] bytes = new byte[length];
+//
+// src.readBytes(bytes, srcIndex, length);
+//
+// writeBytes(bytes);
+
+ byte[] bytes = src.array();
+
+ writeBytes(bytes, srcIndex, length);
+ }
}
public void writeBytes(final ByteBuffer src)
@@ -784,5 +800,5 @@
{
UTF8Util.saveUTF(this, utf);
}
-
+
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -378,7 +378,23 @@
{
ByteBuffer newBuffer = ByteBuffer.allocate(buffer.remaining());
newBuffer.put(buffer);
- newBuffer.flip();
+ newBuffer.flip();
return new HornetQByteBufferBackedChannelBuffer(newBuffer);
}
+
+ public HornetQBuffer slice(int index, int length)
+ {
+ int currentPos = buffer.position();
+ int currentLimit = buffer.limit();
+
+ buffer.position(index);
+ buffer.limit(length);
+
+ ByteBuffer sliced = buffer.slice();
+
+ buffer.position(currentPos);
+ buffer.limit(currentLimit);
+
+ return new HornetQByteBufferBackedChannelBuffer(sliced);
+ }
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -20,6 +20,7 @@
import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ScatteringByteChannel;
+import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
@@ -35,6 +36,8 @@
*/
public class HornetQDynamicChannelBuffer extends HornetQAbstractChannelBuffer
{
+ private static final Logger log =
Logger.getLogger(HornetQDynamicChannelBuffer.class);
+
private final int initialCapacity;
private HornetQChannelBuffer buffer = HornetQChannelBuffers.EMPTY_BUFFER;
@@ -199,7 +202,7 @@
@Override
public void writeBytes(final byte[] src, final int srcIndex, final int length)
- {
+ {
ensureWritableBytes(length);
super.writeBytes(src, srcIndex, length);
}
@@ -217,7 +220,7 @@
ensureWritableBytes(src.remaining());
super.writeBytes(src);
}
-
+
@Override
public void writeZero(final int length)
{
@@ -278,5 +281,10 @@
{
return new HornetQDynamicChannelBuffer(buffer.copy().array());
}
+
+ public HornetQBuffer slice(int index, int length)
+ {
+ return buffer.slice(index, length);
+ }
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -313,5 +313,19 @@
{
return new HornetQHeapChannelBuffer(array.clone());
}
+
+ public HornetQBuffer slice(int index, int length)
+ {
+ //FIXME - this is currently very inefficient since we just copy the underlying
array
+ //We should really get rid of these versions of the Netty classes and just use the
real
+ //Netty classes, since these don't have all the functionality and fixes.
+ //However this will introduce a dependency on Netty on core
+
+ byte[] copied = new byte[length];
+
+ System.arraycopy(array, index, copied, 0, length);
+
+ return new HornetQHeapChannelBuffer(copied);
+ }
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -18,7 +18,6 @@
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.message.Message;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
*
@@ -34,9 +33,7 @@
void setDeliveryCount(int deliveryCount);
- void acknowledge() throws HornetQException;
-
- void resetBuffer();
+ void acknowledge() throws HornetQException;
//FIXME - the following are only used for large messages - they should be put
somewhere else:
@@ -56,4 +53,6 @@
boolean waitOutputStreamCompletion(long timeMilliseconds) throws HornetQException;
void setBodyInputStream(InputStream bodyInputStream);
+
+ int getBodySize();
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -17,16 +17,15 @@
import java.io.InputStream;
import java.io.OutputStream;
+import org.hornetq.core.buffers.ResetLimitWrappedHornetQBuffer;
import org.hornetq.core.client.LargeMessageBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.integration.transports.netty.ChannelBufferWrapper;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
-import org.jboss.netty.buffer.ChannelBuffer;
/**
*
@@ -64,15 +63,15 @@
/*
* Construct messages before sending
*/
- ClientMessageImpl(final byte type,
- final boolean durable,
- final long expiration,
- final long timestamp,
- final byte priority,
- final HornetQBuffer buffer)
+ public ClientMessageImpl(final byte type,
+ final boolean durable,
+ final long expiration,
+ final long timestamp,
+ final byte priority,
+ final HornetQBuffer buffer)
{
- super(type, durable, expiration, timestamp, priority, buffer);
-
+ super(type, durable, expiration, timestamp, priority, buffer);
+
this.resetBuffer();
}
@@ -129,11 +128,11 @@
this.largeMessage = largeMessage;
}
- @Override
- public void afterSend()
+ public int getBodySize()
{
+ return buffer.writerIndex() - buffer.readerIndex();
}
-
+
@Override
public String toString()
{
@@ -154,7 +153,7 @@
{
if (largeMessage)
{
- return ((LargeMessageBuffer)getBuffer()).getSize();
+ return ((LargeMessageBuffer)getWholeBuffer()).getSize();
}
else
{
@@ -169,13 +168,13 @@
{
if (largeMessage)
{
- ((LargeMessageBufferImpl)this.getBuffer()).saveBuffer(out);
+ ((LargeMessageBufferImpl)this.getWholeBuffer()).saveBuffer(out);
}
else
{
try
{
- out.write(this.getBuffer().array());
+ out.write(this.getWholeBuffer().array());
}
catch (IOException e)
{
@@ -192,7 +191,7 @@
{
if (largeMessage)
{
- ((LargeMessageBufferImpl)this.getBuffer()).setOutputStream(out);
+ ((LargeMessageBufferImpl)this.getWholeBuffer()).setOutputStream(out);
}
else
{
@@ -208,7 +207,7 @@
{
if (largeMessage)
{
- return
((LargeMessageBufferImpl)this.getBuffer()).waitCompletion(timeMilliseconds);
+ return
((LargeMessageBufferImpl)this.getWholeBuffer()).waitCompletion(timeMilliseconds);
}
else
{
@@ -223,15 +222,10 @@
{
if (largeMessage)
{
- ((LargeMessageBuffer)getBuffer()).discardUnusedPackets();
+ ((LargeMessageBuffer)getWholeBuffer()).discardUnusedPackets();
}
}
- public void setBuffer(final HornetQBuffer buffer)
- {
- this.buffer = buffer;
- }
-
/**
* @return the bodyInputStream
*/
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -63,14 +63,18 @@
public void acquireCredits(int credits) throws InterruptedException
{
// credits += offset;
-
+
+ // log.info("trying to acquire " + credits);
+
checkCredits(credits);
-
+
semaphore.acquire(credits);
}
public void receiveCredits(final int credits, final int offset)
{
+ // log.info("receiving credits " + credits);
+
synchronized (this)
{
arriving -= credits;
@@ -117,6 +121,7 @@
if (toRequest != -1)
{
+ //log.info("sending request for credits " + toRequest);
requestCredits(toRequest);
}
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -32,7 +32,6 @@
import org.hornetq.utils.SimpleString;
import org.hornetq.utils.TokenBucketLimiter;
import org.hornetq.utils.UUIDGenerator;
-import org.jboss.netty.buffer.ChannelBuffers;
/**
* The client-side Producer connectionFactory class.
@@ -304,9 +303,9 @@
}
// msg.getBody() could be Null on LargeServerMessage
- if (msg.getBodyInputStream() == null && msg.getBuffer() != null)
+ if (msg.getBodyInputStream() == null && msg.getWholeBuffer() != null)
{
- msg.getBuffer().readerIndex(0);
+ msg.getWholeBuffer().readerIndex(0);
}
HornetQBuffer headerBuffer = HornetQChannelBuffers.buffer(headerSize);
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -27,7 +27,6 @@
import java.util.concurrent.TimeUnit;
import org.hornetq.core.buffers.HornetQChannelBuffer;
-import org.hornetq.core.buffers.HornetQDynamicChannelBuffer;
import org.hornetq.core.client.LargeMessageBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
@@ -1200,6 +1199,11 @@
{
throw new UnsupportedOperationException();
}
+
+ public HornetQBuffer slice(int index, int length)
+ {
+ throw new UnsupportedOperationException();
+ }
// Package protected ---------------------------------------------
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/management/impl/ManagementHelper.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -118,7 +118,7 @@
paramString = null;
}
- message.getBuffer().writeNullableString(paramString);
+ message.getBodyBuffer().writeNullableString(paramString);
}
private static JSONArray toJSONArray(final Object[] array) throws Exception
@@ -273,7 +273,7 @@
public static Object[] retrieveOperationParameters(final Message message) throws
Exception
{
- String jsonString = message.getBuffer().readNullableString();
+ String jsonString = message.getBodyBuffer().readNullableString();
if (jsonString != null)
{
@@ -314,12 +314,12 @@
resultString = null;
}
- message.getBuffer().writeNullableString(resultString);
+ message.getBodyBuffer().writeNullableString(resultString);
}
public static Object[] getResults(final Message message) throws Exception
{
- String jsonString = message.getBuffer().readNullableString();
+ String jsonString = message.getBodyBuffer().readNullableString();
if (jsonString != null)
{
Modified:
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -416,14 +416,14 @@
final EncodingSupport record,
final int size,
final HornetQChannelBuffer bb)
- {
+ {
bb.writeByte(ADD_RECORD);
bb.writeInt(fileId);
bb.writeLong(id);
bb.writeInt(record.getEncodeSize());
bb.writeByte(recordType);
- record.encode(bb);
- bb.writeInt(size);
+ record.encode(bb);
+ bb.writeInt(size);
}
/**
@@ -511,12 +511,10 @@
final JournalFile file,
final JournalReaderCallback reader) throws
Exception
{
-
file.getFile().open(1);
ByteBuffer wholeFileBuffer = null;
try
{
-
final int filesize = (int)file.getFile().size();
wholeFileBuffer = fileFactory.newBuffer((int)filesize);
@@ -736,13 +734,13 @@
switch (recordType)
{
case ADD_RECORD:
- {
+ {
reader.onReadAddRecord(new RecordInfo(recordID, userRecordType, record,
false));
break;
}
case UPDATE_RECORD:
- {
+ {
reader.onReadUpdateRecord(new RecordInfo(recordID, userRecordType,
record, true));
break;
}
@@ -857,7 +855,7 @@
compactingLock.readLock().lock();
try
- {
+ {
int size = SIZE_ADD_RECORD + record.getEncodeSize();
HornetQChannelBuffer bb = newBuffer(size);
@@ -1706,7 +1704,6 @@
int lastDataPos = SIZE_HEADER;
final AtomicLong maxID = new AtomicLong(-1);
- // long maxID = -1;
for (final JournalFile file : orderedFiles)
{
Modified: branches/20-optimisation/src/main/org/hornetq/core/message/Message.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/message/Message.java 2009-11-21
23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/src/main/org/hornetq/core/message/Message.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -64,6 +64,9 @@
int getEncodeSize();
boolean isLargeMessage();
+
+ HornetQBuffer getBodyBuffer();
+
// Properties
// ------------------------------------------------------------------
@@ -173,7 +176,7 @@
int getHeadersAndPropertiesEncodeSize();
- HornetQBuffer getBuffer();
+ HornetQBuffer getWholeBuffer();
void setBuffer(HornetQBuffer buffer);
@@ -188,11 +191,7 @@
// Sending stuff
-
- void afterSend();
-
- boolean isBufferWritten();
-
+
boolean isEncodedToBuffer();
void decodeFromWire(HornetQBuffer buffer);
Modified:
branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -13,7 +13,6 @@
package org.hornetq.core.message.impl;
-import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.PACKET_HEADERS_SIZE;
import static org.hornetq.utils.DataConstants.SIZE_BOOLEAN;
import static org.hornetq.utils.DataConstants.SIZE_BYTE;
import static org.hornetq.utils.DataConstants.SIZE_LONG;
@@ -24,6 +23,8 @@
import java.util.Set;
import org.hornetq.core.buffers.HornetQChannelBuffers;
+import org.hornetq.core.buffers.ResetLimitWrappedHornetQBuffer;
+import org.hornetq.core.client.LargeMessageBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.BodyEncoder;
@@ -139,36 +140,11 @@
// Message implementation ----------------------------------------
- public void afterSend()
- {
- }
-
- public boolean isBufferWritten()
- {
- return false;
- }
-
- public void resetBuffer()
- {
- //There is a bug in Netty which requires us to initially write a byte
- if (buffer.capacity() == 0)
- {
- buffer.writeByte((byte)0);
- }
-
- buffer.setIndex(0, PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT);
- }
-
public int getEncodeSize()
{
return encodeSize;
}
- public int getBodySize()
- {
- return buffer.writerIndex();
- }
-
public void encodeHeadersAndProperties(final HornetQBuffer buffer)
{
buffer.writeLong(messageID);
@@ -179,7 +155,7 @@
buffer.writeLong(timestamp);
buffer.writeByte(priority);
properties.encode(buffer);
- encodeSize = buffer.writerIndex();
+ encodeSize = buffer.writerIndex() - PacketImpl.PACKET_HEADERS_SIZE;
}
public void decodeFromWire(final HornetQBuffer buffer)
@@ -197,16 +173,16 @@
}
public void decodeHeadersAndProperties(final HornetQBuffer buffer)
- {
- messageID = buffer.readLong();
- destination = buffer.readSimpleString();
+ {
+ messageID = buffer.readLong();
+ destination = buffer.readSimpleString();
type = buffer.readByte();
durable = buffer.readBoolean();
expiration = buffer.readLong();
timestamp = buffer.readLong();
priority = buffer.readByte();
properties.decode(buffer);
- encodeSize = buffer.readerIndex();
+ encodeSize = buffer.readerIndex() - PacketImpl.PACKET_HEADERS_SIZE;
}
public long getMessageID()
@@ -278,9 +254,7 @@
return System.currentTimeMillis() - expiration >= 0;
}
-
-
public Map<String, Object> toMap()
{
Map<String, Object> map = new HashMap<String, Object>();
@@ -597,27 +571,62 @@
return properties;
}
- public HornetQBuffer getBuffer()
+ public HornetQBuffer getWholeBuffer()
{
return buffer;
}
public void setBuffer(HornetQBuffer buffer)
{
- this.buffer = buffer;
+ this.buffer = buffer;
+
+ if (bodyBuffer != null)
+ {
+ bodyBuffer.setBuffer(buffer);
+ }
}
public BodyEncoder getBodyEncoder()
{
return new DecodingContext();
}
+
+ private ResetLimitWrappedHornetQBuffer bodyBuffer;
+ public HornetQBuffer getBodyBuffer()
+ {
+ if (bodyBuffer == null)
+ {
+ if (buffer instanceof LargeMessageBuffer == false)
+ {
+ bodyBuffer = new
ResetLimitWrappedHornetQBuffer(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT,
buffer);
+ }
+ else
+ {
+ return buffer;
+ }
+ }
+
+ return bodyBuffer;
+ }
+
// Public --------------------------------------------------------
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
+
+ protected void resetBuffer()
+ {
+ // There is a bug in Netty which requires us to initially write a byte
+ if (buffer.capacity() == 0)
+ {
+ buffer.writeByte((byte)0);
+ }
+ buffer.setIndex(0, PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT);
+ }
+
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
@@ -646,7 +655,7 @@
public int encode(HornetQBuffer bufferOut, int size)
{
- bufferOut.writeBytes(getBuffer(), lastPos, size);
+ bufferOut.writeBytes(getWholeBuffer(), lastPos, size);
lastPos += size;
return size;
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -117,11 +117,12 @@
{
PagedMessage msg = new PagedMessageImpl();
msg.decode(fileBuffer);
- if (fileBuffer.readByte() != END_BYTE)
+ byte b = fileBuffer.readByte();
+ if (b != END_BYTE)
{
// Sanity Check: This would only happen if there is a bug on decode
or any internal code, as this
// constraint was already checked
- throw new IllegalStateException("Internal error, it wasn't
possible to locate END_BYTE");
+ throw new IllegalStateException("Internal error, it wasn't
possible to locate END_BYTE " + b);
}
messages.add(msg);
}
@@ -151,10 +152,13 @@
HornetQChannelBuffer wrap = HornetQChannelBuffers.wrappedBuffer(buffer);
wrap.writeByte(START_BYTE);
- wrap.writeInt(message.getEncodeSize());
+ wrap.writeInt(0);
+ int startIndex = wrap.writerIndex();
message.encode(wrap);
+ int endIndex = wrap.writerIndex();
+ wrap.setInt(1, endIndex - startIndex); // The encoded length
wrap.writeByte(END_BYTE);
-
+
buffer.rewind();
file.writeDirect(buffer, false);
Modified:
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -18,6 +18,7 @@
import static org.hornetq.utils.DataConstants.SIZE_LONG;
import org.hornetq.core.buffers.HornetQChannelBuffers;
+import org.hornetq.core.logging.Logger;
import org.hornetq.core.paging.PagedMessage;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.remoting.spi.HornetQBuffer;
@@ -37,6 +38,9 @@
{
// Constants -----------------------------------------------------
+ private static final Logger log = Logger.getLogger(PagedMessageImpl.class);
+
+
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
@@ -107,7 +111,7 @@
message = new ServerMessageImpl();
- message.decodeHeadersAndProperties(buffer);
+ message.decode(buffer);
}
}
@@ -119,7 +123,7 @@
buffer.writeBoolean(message instanceof LargeServerMessage);
buffer.writeInt(message.getEncodeSize());
-
+
message.encode(buffer);
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -280,9 +280,11 @@
}
public void addSize(final ServerMessage message, final boolean add) throws Exception
- {
+ {
long size = message.getMemoryEstimate();
+ //log.info((add ? "adding" : "subtracting") + " message
size " + size);
+
if (add)
{
checkReleaseProducerFlowControlCredits(size);
@@ -300,6 +302,8 @@
public void addSize(final MessageReference reference, final boolean add) throws
Exception
{
long size = MessageReferenceImpl.getMemoryEstimate();
+
+ //log.info((add ? "adding" : "subtracting") + " reference
size " + size);
if (add)
{
Deleted:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/FileLargeServerMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/FileLargeServerMessage.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/FileLargeServerMessage.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -1,432 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.persistence.impl.journal;
-
-import static org.hornetq.utils.DataConstants.SIZE_INT;
-
-import java.nio.ByteBuffer;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.hornetq.core.exception.HornetQException;
-import org.hornetq.core.journal.SequentialFile;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.message.BodyEncoder;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.core.server.LargeServerMessage;
-import org.hornetq.core.server.MessageReference;
-import org.hornetq.core.server.ServerMessage;
-import org.hornetq.core.server.impl.ServerMessageImpl;
-
-/**
- * A JournalLargeServerMessage
- *
- * @author <a href="mailto:clebert.suconic@jboss.org">Clebert
Suconic</a>
- *
- * Created 30-Sep-08 12:02:45 PM
- *
- *
- */
-public class FileLargeServerMessage extends ServerMessageImpl implements
LargeServerMessage
-{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(FileLargeServerMessage.class);
-
- private static boolean isTrace = log.isTraceEnabled();
-
- // Attributes ----------------------------------------------------
-
- private final JournalStorageManager storageManager;
-
- private LargeServerMessage linkMessage;
-
- // We should only use the NIO implementation on the Journal
- private SequentialFile file;
-
- private long bodySize = -1;
-
- private final AtomicInteger delayDeletionCount = new AtomicInteger(0);
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public FileLargeServerMessage(final JournalStorageManager storageManager)
- {
- this.storageManager = storageManager;
- }
-
- /**
- * Copy constructor
- * @param copy
- * @param fileCopy
- */
- private FileLargeServerMessage(final FileLargeServerMessage copy, final SequentialFile
fileCopy, final long newID)
- {
- super(copy);
- this.linkMessage = copy;
- storageManager = copy.storageManager;
- file = fileCopy;
- bodySize = copy.bodySize;
- setMessageID(newID);
- }
-
- // Public --------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.hornetq.core.server.LargeServerMessage#addBytes(byte[])
- */
- public synchronized void addBytes(final byte[] bytes) throws Exception
- {
- validateFile();
-
- if (!file.isOpen())
- {
- file.open();
- }
-
- storageManager.addBytesToLargeMessage(file, this.getMessageID(), bytes);
-
- bodySize += bytes.length;
- }
-
- public void encodeBody(final HornetQBuffer bufferOut, BodyEncoder context, int size)
- {
- try
- {
- // This could maybe be optimized (maybe reading directly into bufferOut)
- ByteBuffer bufferRead = ByteBuffer.allocate(size);
-
- int bytesRead = context.encode(bufferRead);
-
- bufferRead.flip();
-
- if (bytesRead > 0)
- {
- bufferOut.writeBytes(bufferRead.array(), 0, bytesRead);
- }
-
- }
- catch (Exception e)
- {
- throw new RuntimeException(e.getMessage(), e);
- }
- }
-
- @Override
- public synchronized int getBodySize()
- {
- try
- {
- validateFile();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e.getMessage(), e);
- }
- return (int)Math.min(bodySize, Integer.MAX_VALUE);
- }
-
- @Override
- public synchronized long getLargeBodySize()
- {
- try
- {
- validateFile();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e.getMessage(), e);
- }
- return bodySize;
- }
-
- @Override
- public synchronized int getEncodeSize()
- {
- return getHeadersAndPropertiesEncodeSize();
- }
-
-// @Override
-// public void encode(final HornetQBuffer buffer)
-// {
-// encodeHeadersAndProperties(buffer);
-// }
-
- @Override
- public void decodeHeadersAndProperties(final HornetQBuffer buffer)
- {
- file = null;
- decodeHeadersAndProperties(buffer);
- }
-
- public synchronized void incrementDelayDeletionCount()
- {
- this.delayDeletionCount.incrementAndGet();
- }
-
- public synchronized void decrementDelayDeletionCount() throws Exception
- {
- int count = this.delayDeletionCount.decrementAndGet();
-
- if (count == 0)
- {
- checkDelete();
- }
- }
-
- @Override
- public BodyEncoder getBodyEncoder()
- {
- return new DecodingContext();
- }
-
- private void checkDelete() throws Exception
- {
- if (getRefCount() <= 0)
- {
- if (linkMessage != null)
- {
- // This file is linked to another message, deleting the reference where it
belongs on this case
- linkMessage.decrementDelayDeletionCount();
- }
- else
- {
- if (isTrace)
- {
- log.trace("Deleting file " + file + " as the usage was
complete");
- }
-
- try
- {
- deleteFile();
- }
- catch (Exception e)
- {
- log.error(e.getMessage(), e);
- }
- }
- }
- }
-
- @Override
- public synchronized int decrementRefCount(MessageReference reference) throws
Exception
- {
- int currentRefCount = super.decrementRefCount(reference);
-
- // We use <= as this could be used by load.
- // because of a failure, no references were loaded, so we have 0... and we still
need to delete the associated
- // files
- if (delayDeletionCount.get() <= 0)
- {
- checkDelete();
- }
-
- return currentRefCount;
- }
-
- @Override
- public boolean isLargeMessage()
- {
- return true;
- }
-
- public synchronized void deleteFile() throws Exception
- {
- validateFile();
- releaseResources();
- storageManager.deleteFile(file);
- }
-
- public boolean isFileExists() throws Exception
- {
- SequentialFile localfile = storageManager.createFileForLargeMessage(getMessageID(),
durable);
- return localfile.exists();
- }
-
- // We cache this
- private volatile int memoryEstimate = -1;
-
- @Override
- public synchronized int getMemoryEstimate()
- {
- if (memoryEstimate == -1)
- {
- // The body won't be on memory (aways on-file), so we don't consider
this for paging
- memoryEstimate = getHeadersAndPropertiesEncodeSize() + SIZE_INT +
getEncodeSize() + (16 + 4) * 2 + 1;
- }
-
- return memoryEstimate;
- }
-
- public synchronized void releaseResources()
- {
- if (file != null && file.isOpen())
- {
- try
- {
- file.close();
- }
- catch (Exception e)
- {
- log.error(e.getMessage(), e);
- }
- }
- }
-
- @Override
- public synchronized ServerMessage copy(final long newID) throws Exception
- {
- incrementDelayDeletionCount();
-
- long idToUse = messageID;
-
- if (linkMessage != null)
- {
- idToUse = linkMessage.getMessageID();
- }
-
- SequentialFile newfile = storageManager.createFileForLargeMessage(idToUse,
durable);
-
- ServerMessage newMessage = new FileLargeServerMessage(linkMessage == null ? this
- :
(FileLargeServerMessage)linkMessage,
- newfile,
- newID);
-
- return newMessage;
- }
-
- public SequentialFile getFile()
- {
- return file;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected void finalize() throws Throwable
- {
- releaseResources();
- super.finalize();
- }
-
- // Private -------------------------------------------------------
-
- private synchronized void validateFile() throws Exception
- {
- if (file == null)
- {
- if (messageID <= 0)
- {
- throw new RuntimeException("MessageID not set on LargeMessage");
- }
-
- file = storageManager.createFileForLargeMessage(getMessageID(), durable);
-
- file.open();
-
- bodySize = file.size();
-
- }
- }
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.server.LargeServerMessage#setLinkedMessage(org.hornetq.core.server.LargeServerMessage)
- */
- public void setLinkedMessage(LargeServerMessage message)
- {
- if (file != null)
- {
- // Sanity check.. it shouldn't happen
- throw new IllegalStateException("LargeMessage file was already set");
- }
-
- this.linkMessage = message;
-
- file = storageManager.createFileForLargeMessage(message.getMessageID(), durable);
- try
- {
- file.open();
- this.bodySize = file.size();
- file.close();
- }
- catch (Exception e)
- {
- throw new RuntimeException("could not setup linked file", e);
- }
- }
-
- // Inner classes -------------------------------------------------
-
- class DecodingContext implements BodyEncoder
- {
- private SequentialFile cFile;
-
- public void open() throws HornetQException
- {
- try
- {
- cFile = file.copy();
- cFile.open();
- }
- catch (Exception e)
- {
- throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(),
e);
- }
- }
-
- public void close() throws HornetQException
- {
- try
- {
- cFile.close();
- }
- catch (Exception e)
- {
- throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(),
e);
- }
- }
-
- public int encode(ByteBuffer bufferRead) throws HornetQException
- {
- try
- {
- return cFile.read(bufferRead);
- }
- catch (Exception e)
- {
- throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(),
e);
- }
- }
-
- public int encode(HornetQBuffer bufferOut, int size) throws HornetQException
- {
- // This could maybe be optimized (maybe reading directly into bufferOut)
- ByteBuffer bufferRead = ByteBuffer.allocate(size);
-
- int bytesRead = encode(bufferRead);
-
- bufferRead.flip();
-
- if (bytesRead > 0)
- {
- bufferOut.writeBytes(bufferRead.array(), 0, bytesRead);
- }
-
- return bytesRead;
- }
- }
-}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -408,7 +408,7 @@
public LargeServerMessage createLargeMessage()
{
- return new FileLargeServerMessage(this);
+ return new LargeServerMessageImpl(this);
}
public void addBytesToLargeMessage(SequentialFile file, long messageId, final byte[]
bytes) throws Exception
@@ -430,7 +430,7 @@
replicator.largeMessageBegin(id);
}
- FileLargeServerMessage largeMessage =
(FileLargeServerMessage)createLargeMessage();
+ LargeServerMessageImpl largeMessage =
(LargeServerMessageImpl)createLargeMessage();
HornetQBuffer headerBuffer = HornetQChannelBuffers.wrappedBuffer(header);
@@ -451,8 +451,6 @@
throw new HornetQException(HornetQException.ILLEGAL_STATE, "MessageId was
not assigned to Message");
}
- log.info("storing message");
-
// Note that we don't sync, the add reference that comes immediately after will
sync if appropriate
if (message.isLargeMessage())
@@ -740,7 +738,7 @@
break;
}
case ADD_MESSAGE:
- {
+ {
ServerMessage message = new ServerMessageImpl(record.id);
message.decode(buff);
Copied:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java
(from rev 8349,
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/FileLargeServerMessage.java)
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java
(rev 0)
+++
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -0,0 +1,420 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.persistence.impl.journal;
+
+import static org.hornetq.utils.DataConstants.SIZE_INT;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.hornetq.core.exception.HornetQException;
+import org.hornetq.core.journal.SequentialFile;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.message.BodyEncoder;
+import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.server.LargeServerMessage;
+import org.hornetq.core.server.MessageReference;
+import org.hornetq.core.server.ServerMessage;
+import org.hornetq.core.server.impl.ServerMessageImpl;
+
+/**
+ * A LargeServerMessageImpl
+ *
+ * @author <a href="mailto:clebert.suconic@jboss.org">Clebert
Suconic</a>
+ *
+ * Created 30-Sep-08 12:02:45 PM
+ *
+ *
+ */
+public class LargeServerMessageImpl extends ServerMessageImpl implements
LargeServerMessage
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(LargeServerMessageImpl.class);
+
+ private static boolean isTrace = log.isTraceEnabled();
+
+ // Attributes ----------------------------------------------------
+
+ private final JournalStorageManager storageManager;
+
+ private LargeServerMessage linkMessage;
+
+ // We should only use the NIO implementation on the Journal
+ private SequentialFile file;
+
+ private long bodySize = -1;
+
+ private final AtomicInteger delayDeletionCount = new AtomicInteger(0);
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public LargeServerMessageImpl(final JournalStorageManager storageManager)
+ {
+ this.storageManager = storageManager;
+ }
+
+ /**
+ * Copy constructor
+ * @param copy
+ * @param fileCopy
+ */
+ private LargeServerMessageImpl(final LargeServerMessageImpl copy, final SequentialFile
fileCopy, final long newID)
+ {
+ super(copy);
+ this.linkMessage = copy;
+ storageManager = copy.storageManager;
+ file = fileCopy;
+ bodySize = copy.bodySize;
+ setMessageID(newID);
+ }
+
+ // Public --------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.server.LargeServerMessage#addBytes(byte[])
+ */
+ public synchronized void addBytes(final byte[] bytes) throws Exception
+ {
+ validateFile();
+
+ if (!file.isOpen())
+ {
+ file.open();
+ }
+
+ storageManager.addBytesToLargeMessage(file, this.getMessageID(), bytes);
+
+ bodySize += bytes.length;
+ }
+
+ public void encodeBody(final HornetQBuffer bufferOut, BodyEncoder context, int size)
+ {
+ log.info("large server message, encodebody");
+ try
+ {
+ // This could maybe be optimized (maybe reading directly into bufferOut)
+ ByteBuffer bufferRead = ByteBuffer.allocate(size);
+
+ int bytesRead = context.encode(bufferRead);
+
+ bufferRead.flip();
+
+ if (bytesRead > 0)
+ {
+ bufferOut.writeBytes(bufferRead.array(), 0, bytesRead);
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public synchronized long getLargeBodySize()
+ {
+ try
+ {
+ validateFile();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ return bodySize;
+ }
+
+ @Override
+ public synchronized int getEncodeSize()
+ {
+ return getHeadersAndPropertiesEncodeSize();
+ }
+
+ @Override
+ public void encode(final HornetQBuffer buffer)
+ {
+ super.encodeHeadersAndProperties(buffer);
+ }
+
+ @Override
+ public void decode(final HornetQBuffer buffer)
+ {
+ file = null;
+
+ super.decodeHeadersAndProperties(buffer);
+ }
+
+ public synchronized void incrementDelayDeletionCount()
+ {
+ this.delayDeletionCount.incrementAndGet();
+ }
+
+ public synchronized void decrementDelayDeletionCount() throws Exception
+ {
+ int count = this.delayDeletionCount.decrementAndGet();
+
+ if (count == 0)
+ {
+ checkDelete();
+ }
+ }
+
+ @Override
+ public BodyEncoder getBodyEncoder()
+ {
+ return new DecodingContext();
+ }
+
+ private void checkDelete() throws Exception
+ {
+ if (getRefCount() <= 0)
+ {
+ if (linkMessage != null)
+ {
+ // This file is linked to another message, deleting the reference where it
belongs on this case
+ linkMessage.decrementDelayDeletionCount();
+ }
+ else
+ {
+ if (isTrace)
+ {
+ log.trace("Deleting file " + file + " as the usage was
complete");
+ }
+
+ try
+ {
+ deleteFile();
+ }
+ catch (Exception e)
+ {
+ log.error(e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ @Override
+ public synchronized int decrementRefCount(MessageReference reference) throws
Exception
+ {
+ int currentRefCount = super.decrementRefCount(reference);
+
+ // We use <= as this could be used by load.
+ // because of a failure, no references were loaded, so we have 0... and we still
need to delete the associated
+ // files
+ if (delayDeletionCount.get() <= 0)
+ {
+ checkDelete();
+ }
+
+ return currentRefCount;
+ }
+
+ @Override
+ public boolean isLargeMessage()
+ {
+ return true;
+ }
+
+ public synchronized void deleteFile() throws Exception
+ {
+ validateFile();
+ releaseResources();
+ storageManager.deleteFile(file);
+ }
+
+ public boolean isFileExists() throws Exception
+ {
+ SequentialFile localfile = storageManager.createFileForLargeMessage(getMessageID(),
durable);
+ return localfile.exists();
+ }
+
+ // We cache this
+ private volatile int memoryEstimate = -1;
+
+ @Override
+ public synchronized int getMemoryEstimate()
+ {
+ if (memoryEstimate == -1)
+ {
+ // The body won't be on memory (aways on-file), so we don't consider
this for paging
+ memoryEstimate = getHeadersAndPropertiesEncodeSize() + SIZE_INT +
getEncodeSize() + (16 + 4) * 2 + 1;
+ }
+
+ return memoryEstimate;
+ }
+
+ public synchronized void releaseResources()
+ {
+ if (file != null && file.isOpen())
+ {
+ try
+ {
+ file.close();
+ }
+ catch (Exception e)
+ {
+ log.error(e.getMessage(), e);
+ }
+ }
+ }
+
+ @Override
+ public synchronized ServerMessage copy(final long newID) throws Exception
+ {
+ incrementDelayDeletionCount();
+
+ long idToUse = messageID;
+
+ if (linkMessage != null)
+ {
+ idToUse = linkMessage.getMessageID();
+ }
+
+ SequentialFile newfile = storageManager.createFileForLargeMessage(idToUse,
durable);
+
+ ServerMessage newMessage = new LargeServerMessageImpl(linkMessage == null ? this
+ :
(LargeServerMessageImpl)linkMessage,
+ newfile,
+ newID);
+
+ return newMessage;
+ }
+
+ public SequentialFile getFile()
+ {
+ return file;
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ @Override
+ protected void finalize() throws Throwable
+ {
+ releaseResources();
+ super.finalize();
+ }
+
+ // Private -------------------------------------------------------
+
+ private synchronized void validateFile() throws Exception
+ {
+ if (file == null)
+ {
+ if (messageID <= 0)
+ {
+ throw new RuntimeException("MessageID not set on LargeMessage");
+ }
+
+ file = storageManager.createFileForLargeMessage(getMessageID(), durable);
+
+ file.open();
+
+ bodySize = file.size();
+
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.hornetq.core.server.LargeServerMessage#setLinkedMessage(org.hornetq.core.server.LargeServerMessage)
+ */
+ public void setLinkedMessage(LargeServerMessage message)
+ {
+ if (file != null)
+ {
+ // Sanity check.. it shouldn't happen
+ throw new IllegalStateException("LargeMessage file was already set");
+ }
+
+ this.linkMessage = message;
+
+ file = storageManager.createFileForLargeMessage(message.getMessageID(), durable);
+ try
+ {
+ file.open();
+ this.bodySize = file.size();
+ file.close();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("could not setup linked file", e);
+ }
+ }
+
+ // Inner classes -------------------------------------------------
+
+ class DecodingContext implements BodyEncoder
+ {
+ private SequentialFile cFile;
+
+ public void open() throws HornetQException
+ {
+ try
+ {
+ cFile = file.copy();
+ cFile.open();
+ }
+ catch (Exception e)
+ {
+ throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(),
e);
+ }
+ }
+
+ public void close() throws HornetQException
+ {
+ try
+ {
+ cFile.close();
+ }
+ catch (Exception e)
+ {
+ throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(),
e);
+ }
+ }
+
+ public int encode(ByteBuffer bufferRead) throws HornetQException
+ {
+ try
+ {
+ return cFile.read(bufferRead);
+ }
+ catch (Exception e)
+ {
+ throw new HornetQException(HornetQException.INTERNAL_ERROR, e.getMessage(),
e);
+ }
+ }
+
+ public int encode(HornetQBuffer bufferOut, int size) throws HornetQException
+ {
+ // This could maybe be optimized (maybe reading directly into bufferOut)
+ ByteBuffer bufferRead = ByteBuffer.allocate(size);
+
+ int bytesRead = encode(bufferRead);
+
+ bufferRead.flip();
+
+ if (bytesRead > 0)
+ {
+ bufferOut.writeBytes(bufferRead.array(), 0, bytesRead);
+ }
+
+ return bytesRead;
+ }
+ }
+}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -97,7 +97,7 @@
public HornetQBuffer createBuffer(final int size)
{
- return HornetQChannelBuffers.buffer(size);
+ return HornetQChannelBuffers.dynamicBuffer(size);
}
public Object getID()
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -89,7 +89,16 @@
{
//We re-use the same packet buffer - but we need to change the extra data
- HornetQBuffer buffer = serverMessage.getBuffer();
+ //Since many consumers could be delivering the same message concurrently, we must
copy the buffer before sending
+ //since otherwise they will all write different consumer ids and delivering counts
on the same buffer concurrently
+ //and indexes will get screwed up
+
+ //TODO - optimise this
+ HornetQBuffer origBuffer = serverMessage.getWholeBuffer();
+
+ HornetQBuffer buffer = origBuffer.copy();
+
+ buffer.setIndex(origBuffer.readerIndex(), origBuffer.writerIndex());
if (serverMessage.isEncodedToBuffer())
{
@@ -104,11 +113,18 @@
//Message hasn't been encoded yet - probably it's something like a
notification message generated on the server
+ //End of message position
+ buffer.writeInt(0);
+
// We now write the message headers and properties
serverMessage.encodeHeadersAndProperties(buffer);
- serverMessage.setEndMessagePosition(buffer.writerIndex());
+ int endMessage = buffer.writerIndex();
+ buffer.setInt(afterBody, endMessage);
+
+ serverMessage.setEndMessagePosition(endMessage);
+
//Now we need to fill in the afterBody
buffer.setInt(PacketImpl.PACKET_HEADERS_SIZE, afterBody);
}
@@ -128,13 +144,7 @@
buffer.writeByte(type);
buffer.writeLong(channelID);
- //And fill in the message id, since this was set on the server side so won't
already be in the buffer
-
- buffer.writerIndex(buffer.readInt(PacketImpl.PACKET_HEADERS_SIZE));
- buffer.writeLong(serverMessage.getMessageID());
-
- //Set the reader and writer position to be read fully by remoting
- buffer.setIndex(0, size);
+ buffer.writerIndex(size);
return buffer;
}
@@ -151,10 +161,12 @@
//At this point standard headers have been decoded and we are positioned at the
beginning of the body
int bodyStart = buffer.readerIndex();
-
+
// We now read message headers/properties
buffer.readerIndex(afterBody);
+
+ int endMessage = buffer.readInt();
clientMessage.decodeFromWire(buffer);
@@ -169,9 +181,9 @@
size = buffer.readerIndex();
// Set reader index back to beginning of body
+
+ buffer.setIndex(bodyStart, afterBody);
- buffer.readerIndex(bodyStart);
-
clientMessage.setBuffer(buffer);
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -19,9 +19,7 @@
import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.ServerMessage;
import org.hornetq.core.server.impl.ServerMessageImpl;
-import org.hornetq.integration.transports.netty.ChannelBufferWrapper;
import org.hornetq.utils.DataConstants;
-import org.jboss.netty.buffer.ChannelBuffer;
/**
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
@@ -43,7 +41,7 @@
private ServerMessage receivedMessage;
private boolean requiresResponse;
-
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -93,13 +91,15 @@
*
* Then the message body:
*
- * bodySize:int
+ * position of end of body: int
* body:byte[]
*
* {Note we store the message body before the message headers/properties since this
allows the user to
* construct a message, add stuff to the body buffer, and send it without us having
to copy the body into a new
* buffer before sending it, this minmises buffer copying}
*
+ * position of end of encoded message headers/properties: int
+ *
* Then followed by the message headers and properties:
*
* messageID:long
@@ -115,15 +115,24 @@
*
*/
- HornetQBuffer buffer = sentMessage.getBuffer();
+ HornetQBuffer buffer = sentMessage.getWholeBuffer();
// The body will already be written (if any) at this point, so we take note of the
position of the end of the
// body
int afterBody = buffer.writerIndex();
+
+ //The next int is the position of after the encoded message headers/properties, so
we skip this for now
+ buffer.writeInt(0);
// We now write the message headers and properties
sentMessage.encodeHeadersAndProperties(buffer);
+
+ //Write the position of the end of the message
+
+ int endMessage = buffer.writerIndex();
+
+ buffer.setInt(afterBody, endMessage);
// We now write the extra data for the packet
buffer.writeBoolean(requiresResponse);
@@ -133,7 +142,7 @@
// We now set the standard packet headers at the beginning of the buffer
- buffer.writerIndex(0);
+ buffer.clear();
int len = size - DataConstants.SIZE_INT;
buffer.writeInt(len);
@@ -145,14 +154,14 @@
// And we set the indexes back for reading and writing
buffer.setIndex(0, size);
-
+
//We must make a copy of the buffer, since the message might get sent again, and
the body might get read or written
//this might occur while the same send is in operatio since netty send is asynch
//this could cause incorrect data to be send and/or reader/writer positions to
become corrupted
HornetQBuffer newBuffer = buffer.copy();
- newBuffer.setIndex(0, afterBody);
+ newBuffer.setIndex(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT,
afterBody);
this.sentMessage.setBuffer(newBuffer);
@@ -169,18 +178,22 @@
// At this point, the standard packet headers will already have been read
// We read the position of the end of the body - this is where the message headers
and properties are stored
- int afterBody = buffer.readInt();
-
+ int afterBody = buffer.readInt();
+
+ buffer.setIndex(afterBody, buffer.writerIndex());
+
+ int endMessage = buffer.readInt();
+
+ receivedMessage.setEndMessagePosition(endMessage);
+
// We now read message headers/properties
-
- buffer.setIndex(afterBody, buffer.writerIndex());
-
+
receivedMessage.decodeFromWire(buffer);
//We store the position of the end of the encoded message, where the extra data
starts - this
//will be needed if we re-deliver this packet, since we need to reset to there to
rewrite the extra data
//for the different packet
- receivedMessage.setEndMessagePosition(buffer.readerIndex());
+ //receivedMessage.setEndMessagePosition(endMessage);
// And we read extra data in the packet
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -13,8 +13,6 @@
package org.hornetq.core.remoting.spi;
-import java.nio.ByteBuffer;
-
import org.hornetq.utils.SimpleString;
/**
@@ -127,4 +125,6 @@
byte[] array();
HornetQBuffer copy();
+
+ HornetQBuffer slice(int index, int length);
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -67,4 +67,6 @@
void setEndMessagePosition(int pos);
int getEndMessagePosition();
+
+ void encodeMessageIDToBuffer();;
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -64,25 +64,23 @@
* Construct a MessageImpl from storage
*/
public ServerMessageImpl(final long messageID)
- {
- super(messageID);
-
- log.info("creating server message from storage, with id " + messageID);
+ {
+ super(messageID);
}
-
+
/*
* Constructor when creating a ServerMessage for sending - e.g. notification
*/
public ServerMessageImpl(final long messageID, final HornetQBuffer buffer)
{
super(messageID);
-
+
this.buffer = buffer;
-
- //Must align the body after the packet headers
+
+ // Must align the body after the packet headers
resetBuffer();
}
-
+
/*
* Copy constructor
*/
@@ -97,22 +95,9 @@
timestamp = other.getTimestamp();
priority = other.getPriority();
properties = new TypedProperties(other.getProperties());
- buffer = other.getBuffer();
+ buffer = other.getWholeBuffer();
}
-// /**
-// * Only used in testing
-// */
-// public ServerMessageImpl(final byte type,
-// final boolean durable,
-// final long expiration,
-// final long timestamp,
-// final byte priority,
-// final HornetQBuffer buffer)
-// {
-// super(type, durable, expiration, timestamp, priority, buffer);
-// }
-
public void setMessageID(final long id)
{
messageID = id;
@@ -186,7 +171,7 @@
public long getLargeBodySize()
{
- return getBodySize();
+ return -1;
}
public int getMemoryEstimate()
@@ -260,7 +245,7 @@
putLongProperty(HDR_ACTUAL_EXPIRY_TIME, actualExpiryTime);
}
-
+
setNeedsEncoding();
}
@@ -313,9 +298,7 @@
return false;
}
}
-
-
@Override
public String toString()
{
@@ -326,91 +309,111 @@
getDestination() +
"]";
}
-
- //FIXME - this is stuff that is only used in large messages
-
- //This is only valid on the client side - why is it here?
+
+ // FIXME - this is stuff that is only used in large messages
+
+ // This is only valid on the client side - why is it here?
public InputStream getBodyInputStream()
{
return null;
}
-
-
-
+
// Encoding stuff
-
-
+
public void setNeedsEncoding()
{
- //This wil force the message to be re-encoded if it gets sent to a client
- //Typically this is called after properties or headers are changed on the server
side
+ // This wil force the message to be re-encoded if it gets sent to a client
+ // Typically this is called after properties or headers are changed on the server
side
this.encodedToBuffer = false;
}
-
+
private int endMessagePosition;
-
+
public void setEndMessagePosition(int pos)
{
this.endMessagePosition = pos;
}
-
+
public int getEndMessagePosition()
{
return this.endMessagePosition;
}
-
+
+ public void encodeToWire()
+ {
+ }
+
// EncodingSupport implementation
-
+
// Used when storing to/from journal
-
+
public void encode(final HornetQBuffer buffer)
{
- //Encode the message to a buffer for storage in the journal
-
+ // Encode the message to a buffer for storage in the journal
+
if (this.encodedToBuffer)
{
- //The body starts after the standard packet headers
+ // The body starts after the standard packet headers
int bodyStart = PacketImpl.PACKET_HEADERS_SIZE;
-
+
int end = this.endMessagePosition;
- buffer.writeBytes(this.buffer, bodyStart, end);
+ buffer.writeBytes(this.buffer, bodyStart, end - bodyStart);
}
else
{
- //encodeToBuffer();
-
+ // encodeToBuffer();
+
throw new IllegalStateException("Not encoded to buffer and storing to
journal");
- }
+ }
}
-
+
public void decode(final HornetQBuffer buffer)
{
- //TODO optimise
+ // TODO optimise
+
+ int start = buffer.readerIndex();
+
+ int bodyEndPos = buffer.readInt();
- log.info("decoding server message");
+ this.endMessagePosition = buffer.readInt(bodyEndPos -
PacketImpl.PACKET_HEADERS_SIZE + start);
+ int endPos = endMessagePosition + start -
+ PacketImpl.PACKET_HEADERS_SIZE;
+
this.buffer = HornetQChannelBuffers.dynamicBuffer(1500);
-
- //work around Netty bug
+
+ // work around Netty bug
this.buffer.writeByte((byte)0);
-
+
this.buffer.setIndex(0, PacketImpl.PACKET_HEADERS_SIZE);
+
+ this.buffer.writeBytes(buffer, start, endPos - start);
- this.buffer.writeBytes(buffer, 0, buffer.readableBytes());
-
-
+ // Position to beginning of encoded message headers/properties
+
+ this.buffer.readerIndex(0);
+
//Position to beginning of encoded message headers/properties
- int msgHeadersPos = this.buffer.readInt(PacketImpl.PACKET_HEADERS_SIZE);
-
- this.buffer.readerIndex(msgHeadersPos);
-
+ this.buffer.readerIndex(bodyEndPos + DataConstants.SIZE_INT);
+
this.decodeHeadersAndProperties(this.buffer);
- log.info("priority is now " + this.getPriority());
+ buffer.setIndex(endPos, buffer.capacity());
-
+ this.encodedToBuffer = true;
}
+ public void encodeMessageIDToBuffer()
+ {
+ // We first set the message id - this needs to be set on the buffer since this
buffer will be re-used
+
+ buffer.readerIndex(0);
+
+ buffer.writerIndex(buffer.readInt(PacketImpl.PACKET_HEADERS_SIZE) +
DataConstants.SIZE_INT);
+
+ buffer.writeLong(messageID);
+ }
+
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -1435,6 +1435,8 @@
public void handleSendLargeMessage(final SessionSendLargeMessage packet)
{
+ log.info("Got large message on server");
+
// need to create the LargeMessage before continue
long id = storageManager.generateUniqueID();
@@ -1464,6 +1466,7 @@
long id = storageManager.generateUniqueID();
message.setMessageID(id);
+ message.encodeMessageIDToBuffer();
if (message.getDestination().equals(managementAddress))
{
@@ -1573,7 +1576,7 @@
final CreditManagerHolder holder = this.getCreditManagerHolder(address);
int credits = packet.getCredits();
-
+
int gotCredits = holder.manager.acquireCredits(credits, new
CreditsAvailableRunnable()
{
public boolean run(final int credits)
@@ -1593,6 +1596,8 @@
}
}
});
+
+ //log.info("session requesting " + credits + " got " +
gotCredits);
if (gotCredits > 0)
{
@@ -1899,6 +1904,8 @@
*/
private void releaseOutStanding(final ServerMessage message, final int credits) throws
Exception
{
+ //log.info("releasing outstanding credits " + credits);
+
CreditManagerHolder holder = getCreditManagerHolder(message);
holder.outstandingCredits -= credits;
@@ -1941,6 +1948,8 @@
private void sendProducerCredits(final CreditManagerHolder holder, final int credits,
final SimpleString address)
{
holder.outstandingCredits += credits;
+
+ // log.info("sending producer credits " + credits);
Packet packet = new SessionProducerCreditsMessage(credits, address, -1);
Modified:
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -33,7 +33,6 @@
{
private static final Logger log = Logger.getLogger(ChannelBufferWrapper.class);
-
private final ChannelBuffer buffer;
/**
@@ -94,7 +93,7 @@
{
return buffer.readInt();
}
-
+
public int readInt(final int pos)
{
return buffer.getInt(pos);
@@ -284,8 +283,8 @@
* @see org.hornetq.core.remoting.spi.HornetQBuffer#readString()
*/
public String readString()
- {
- int len = readInt();
+ {
+ int len = readInt();
char[] chars = new char[len];
for (int i = 0; i < len; i++)
{
@@ -382,12 +381,12 @@
* @see org.hornetq.core.remoting.spi.HornetQBuffer#writeString(java.lang.String)
*/
public void writeString(final String val)
- {
+ {
writeInt(val.length());
for (int i = 0; i < val.length(); i++)
{
writeShort((short)val.charAt(i));
- }
+ }
}
/* (non-Javadoc)
@@ -405,10 +404,15 @@
{
return buffer;
}
-
+
public HornetQBuffer copy()
{
return new ChannelBufferWrapper(buffer.copy(0, buffer.capacity()));
}
+ public HornetQBuffer slice(int index, int length)
+ {
+ return new ChannelBufferWrapper(buffer.slice(index, length));
+ }
+
}
Modified:
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -13,12 +13,14 @@
package org.hornetq.integration.transports.netty;
+import org.hornetq.core.buffers.HornetQChannelBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.handler.ssl.SslHandler;
@@ -117,9 +119,26 @@
write(buffer, false);
}
- public void write(final HornetQBuffer buffer, final boolean flush)
+ public void write(HornetQBuffer buffer, final boolean flush)
{
- ChannelFuture future = channel.write(buffer.getUnderlyingBuffer());
+ Object underlying = buffer.getUnderlyingBuffer();
+
+ if (underlying instanceof ChannelBuffer == false)
+ {
+ //Need to copy it
+
+ //TODO we can avoid this if we use Netty buffers everywhere!!
+
+ HornetQBuffer hq = (HornetQBuffer)underlying;
+
+ ChannelBuffer cb = ChannelBuffers.copiedBuffer(hq.array());
+
+ cb.setIndex(hq.readerIndex(), hq.writerIndex());
+
+ underlying = cb;
+ }
+
+ ChannelFuture future = channel.write(underlying);
if (flush)
{
Modified:
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -47,6 +47,8 @@
// Attributes ----------------------------------------------------
+ private int bodyLength;
+
// Constructor ---------------------------------------------------
/*
@@ -387,6 +389,8 @@
if (!readOnly)
{
readOnly = true;
+
+ bodyLength = message.getBodySize();
getBuffer().resetReaderIndex();
}
@@ -395,6 +399,13 @@
getBuffer().resetReaderIndex();
}
}
+
+ public void doBeforeReceive() throws Exception
+ {
+ bodyLength = message.getBodySize();
+
+ super.doBeforeReceive();
+ }
// HornetQRAMessage overrides ----------------------------------------
@@ -409,7 +420,7 @@
{
checkRead();
- return message.getLargeBodySize();
+ return bodyLength;
}
public void doBeforeSend() throws Exception
@@ -432,7 +443,7 @@
private HornetQBuffer getBuffer()
{
- return message.getBuffer();
+ return message.getBodyBuffer();
}
// Inner classes -------------------------------------------------
Modified: branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMapMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMapMessage.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMapMessage.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -70,6 +70,10 @@
{
super(message, session);
}
+
+ public HornetQMapMessage()
+ {
+ }
/**
*
@@ -366,7 +370,7 @@
public void doBeforeSend() throws Exception
{
- map.encode(message.getBuffer());
+ map.encode(message.getBodyBuffer());
super.doBeforeSend();
}
@@ -375,7 +379,7 @@
{
super.doBeforeReceive();
- map.decode(message.getBuffer());
+ map.decode(message.getBodyBuffer());
}
// Package protected ---------------------------------------------
Modified: branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -213,7 +213,7 @@
// Read-only?
protected boolean readOnly;
- // Read-only?
+ // Properties read-only?
protected boolean propertiesReadOnly;
// Cache it
@@ -268,6 +268,10 @@
{
this(foreign, HornetQMessage.TYPE, session);
}
+
+ public HornetQMessage()
+ {
+ }
protected HornetQMessage(final Message foreign, final byte type, final ClientSession
session) throws JMSException
{
@@ -339,7 +343,7 @@
msgID = jmsMessageID;
}
-
+
public long getJMSTimestamp() throws JMSException
{
return message.getTimestamp();
@@ -850,6 +854,11 @@
// Public --------------------------------------------------------
+ public void resetMessageID(String msgID)
+ {
+ this.msgID = msgID;
+ }
+
public ClientMessage getCoreMessage()
{
return message;
@@ -857,12 +866,12 @@
public void doBeforeSend() throws Exception
{
- message.getBuffer().resetReaderIndex();
+ message.getBodyBuffer().resetReaderIndex();
}
public void doBeforeReceive() throws Exception
{
- HornetQBuffer body = message.getBuffer();
+ HornetQBuffer body = message.getBodyBuffer();
if (body != null)
{
@@ -965,11 +974,6 @@
}
}
-// protected HornetQBuffer getBody()
-// {
-// return message.getBody();
-// }
-
// Private ------------------------------------------------------------
private void checkStream() throws JMSException
Modified:
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessageProducer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessageProducer.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessageProducer.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -404,8 +404,12 @@
if (!disableMessageID)
{
// Generate an id
+
+ SimpleString msgID = generateMessageID();
- msg.getCoreMessage().putStringProperty(HornetQMessage.HORNETQ_MESSAGE_ID,
generateOldMessageID());
+ msg.getCoreMessage().putStringProperty(HornetQMessage.HORNETQ_MESSAGE_ID,
msgID);
+
+ msg.resetMessageID(msgID.toString());
}
if (foreign)
@@ -476,14 +480,14 @@
return new SimpleString(bytes);
}
- private SimpleString generateOldMessageID()
- {
- SimpleString ss = new SimpleString(messageIDPrefix.getData());
-
- ss.concat(String.valueOf(sequenceNumber++));
-
- return ss;
- }
+// private SimpleString generateOldMessageID()
+// {
+// SimpleString ss = new SimpleString(messageIDPrefix.getData());
+//
+// ss.concat(String.valueOf(sequenceNumber++));
+//
+// return ss;
+// }
private void checkClosed() throws JMSException
{
Modified:
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQObjectMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQObjectMessage.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQObjectMessage.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -15,7 +15,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
@@ -25,15 +24,13 @@
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientSession;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* This class implements javax.jms.ObjectMessage
*
* Don't used ObjectMessage if you want good performance!
*
- * Java Serialization is slooooow!
+ * Serialization is slooooow!
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @author <a href="mailto:ovidiu@feodorov.com">Ovidiu
Feodorov</a>
@@ -47,13 +44,12 @@
{
// Constants -----------------------------------------------------
- public static final Logger log = Logger.getLogger(HornetQObjectMessage.class);
-
public static final byte TYPE = 2;
// Attributes ----------------------------------------------------
- private Serializable object;
+ // keep a snapshot of the Serializable Object as a byte[] to provide Object isolation
+ private byte[] data;
// Static --------------------------------------------------------
@@ -88,22 +84,30 @@
public void doBeforeSend() throws Exception
{
+ message.getBodyBuffer().clear();
+ if (data != null)
+ {
+ message.getBodyBuffer().writeInt(data.length);
+ message.getBodyBuffer().writeBytes(data);
+ }
+
super.doBeforeSend();
}
public void doBeforeReceive() throws Exception
{
super.doBeforeReceive();
-
- HornetQBuffer buffer = message.getBuffer();
-
- byte[] bytes = new byte[buffer.writerIndex() - buffer.readerIndex()];
-
- buffer.readBytes(bytes);
+ try
+ {
+ int len = message.getBodyBuffer().readInt();
+ data = new byte[len];
+ message.getBodyBuffer().readBytes(data);
+ }
+ catch (Exception e)
+ {
+ data = null;
+ }
- ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
-
- object = (Serializable)ois.readObject();
}
// ObjectMessage implementation ----------------------------------
@@ -112,52 +116,57 @@
{
checkWrite();
- this.object = object;
-
-// This is actually slower than serializing into a byte[] first
-// try
-// {
-// ObjectOutputStream oos = new ObjectOutputStream(new
BufferOutputStream(message.getBuffer()));
-//
-// oos.writeObject(object);
-//
-// oos.flush();
-// }
-// catch (IOException e)
-// {
-// log.error("Failed to serialise object", e);
-// }
-
- //It's actually faster to serialize into a ByteArrayOutputStream than direct
into the buffer
- try
+ if (object != null)
{
- ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
-
- ObjectOutputStream oos = new ObjectOutputStream(baos);
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
- oos.writeObject(object);
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.flush();
-
- message.getBuffer().writeBytes(baos.toByteArray());
+ oos.writeObject(object);
+
+ oos.flush();
+
+ data = baos.toByteArray();
+ }
+ catch (Exception e)
+ {
+ JMSException je = new JMSException("Failed to serialize object");
+ je.setLinkedException(e);
+ throw je;
+ }
}
- catch (IOException e)
- {
- log.error("Failed to serialise object", e);
- }
}
// lazy deserialize the Object the first time the client requests it
public Serializable getObject() throws JMSException
{
- return object;
+ if (data == null || data.length == 0)
+ {
+ return null;
+ }
+
+ try
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(data);
+ ObjectInputStream ois = new
org.hornetq.utils.ObjectInputStreamWithClassLoader(bais);
+ Serializable object = (Serializable)ois.readObject();
+ return object;
+ }
+ catch (Exception e)
+ {
+ JMSException je = new JMSException(e.getMessage());
+ je.setStackTrace(e.getStackTrace());
+ throw je;
+ }
}
public void clearBody() throws JMSException
{
super.clearBody();
- object = null;
+ data = null;
}
// Package protected ---------------------------------------------
@@ -167,36 +176,4 @@
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
-
-// private static class BufferOutputStream extends OutputStream
-// {
-// private HornetQBuffer buffer;
-//
-// BufferOutputStream(final HornetQBuffer buffer)
-// {
-// this.buffer = buffer;
-// }
-//
-// @Override
-// public void write(final int b) throws IOException
-// {
-// buffer.writeByte((byte)b);
-// }
-// }
-//
-// private static class BufferInputStream extends InputStream
-// {
-// private HornetQBuffer buffer;
-//
-// BufferInputStream(final HornetQBuffer buffer)
-// {
-// this.buffer = buffer;
-// }
-//
-// @Override
-// public int read() throws IOException
-// {
-// return buffer.readByte();
-// }
-// }
}
Modified:
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -84,6 +84,10 @@
// Ignore
}
}
+
+ public HornetQStreamMessage()
+ {
+ }
// Public --------------------------------------------------------
@@ -561,7 +565,7 @@
private HornetQBuffer getBuffer()
{
- return message.getBuffer();
+ return message.getBodyBuffer();
}
// Inner classes -------------------------------------------------
Modified:
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -73,7 +73,7 @@
{
super(foreign, HornetQTextMessage.TYPE, session);
- text = new SimpleString(foreign.getText());
+ setText(foreign.getText());
}
// Public --------------------------------------------------------
@@ -89,12 +89,20 @@
{
checkWrite();
- this.text = new SimpleString(text);
+ HornetQBuffer buff = message.getBodyBuffer();
- //Reset buffer to just after standard headers space
- message.resetBuffer();
+ buff.clear();
- message.getBuffer().writeNullableSimpleString(this.text);
+ if (text != null)
+ {
+ this.text = new SimpleString(text);
+
+ buff.writeNullableSimpleString(this.text);
+ }
+ else
+ {
+ this.text = null;
+ }
}
public String getText() throws JMSException
@@ -118,11 +126,16 @@
// HornetQRAMessage override -----------------------------------------
+ public void doBeforeSend() throws Exception
+ {
+ super.doBeforeSend();
+ }
+
public void doBeforeReceive() throws Exception
{
super.doBeforeReceive();
- text = message.getBuffer().readNullableSimpleString();
+ text = message.getBodyBuffer().readNullableSimpleString();
}
// Package protected ---------------------------------------------
Modified:
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java
===================================================================
---
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -806,7 +806,7 @@
TextMessage m = (TextMessage)queueConsumer.receive(1500);
assertEquals("One", m.getText());
-
+
queueConsumer.close();
consumerSession.commit();
@@ -818,9 +818,9 @@
m = (TextMessage)queueConsumer2.receive(1500);
assertNotNull(m);
+
+ assertEquals("Two", m.getText());
- assertEquals(m.getText(), "Two");
-
consumerSession.commit();
}
finally
@@ -835,6 +835,7 @@
}
}
}
+
public void testRedel0() throws Exception
{
Modified:
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSExpirationHeaderTest.java
===================================================================
---
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSExpirationHeaderTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSExpirationHeaderTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -14,6 +14,7 @@
package org.hornetq.jms.tests.message;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.jms.DeliveryMode;
import javax.jms.Message;
@@ -231,11 +232,9 @@
assertEquals(m.getJMSMessageID(), result.getJMSMessageID());
}
-
-
public void testExpirationOnReceive() throws Exception
{
- expectedMessage = new HornetQMessage();
+ final AtomicBoolean received = new AtomicBoolean(true);
queueProducer.send(queueProducerSession.createMessage(),
DeliveryMode.NON_PERSISTENT, 4, 2000);
@@ -258,6 +257,11 @@
//NOTE on close, the receive() call will return with null
log.trace("Receive exited without exception:" +
expectedMessage);
+
+ if (expectedMessage == null)
+ {
+ received.set(false);
+ }
}
catch(Exception e)
{
@@ -287,7 +291,7 @@
log.trace("Expected message:" + expectedMessage);
- assertNull(expectedMessage);
+ assertFalse(received.get());
}
/*
Modified:
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSMessageIDHeaderTest.java
===================================================================
---
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSMessageIDHeaderTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/JMSMessageIDHeaderTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -48,9 +48,26 @@
m.setJMSMessageID("ID:something");
queueProducer.send(m);
-
+
assertFalse("ID:something".equals(m.getJMSMessageID()));
+ }
+ finally
+ {
+ removeAllMessages(queue1.getQueueName(), true);
+ }
+ }
+
+ public void testJMSMessageID() throws Exception
+ {
+ try
+ {
+ Message m = queueProducerSession.createMessage();;
+ assertNull(m.getJMSMessageID());
+ queueProducer.send(m);
+
+ assertNotNull(m.getJMSMessageID());
+ assertTrue(m.getJMSMessageID().startsWith("ID:"));
}
finally
{
Modified:
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageBodyTest.java
===================================================================
---
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageBodyTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageBodyTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -45,1509 +45,1624 @@
*/
public class MessageBodyTest extends HornetQServerTestCase
{
- // Constants -----------------------------------------------------
+ // Constants -----------------------------------------------------
- // Static --------------------------------------------------------
+ // Static --------------------------------------------------------
- // Attributes ----------------------------------------------------
+ // Attributes ----------------------------------------------------
- protected Connection producerConnection, consumerConnection;
+ protected Connection producerConnection, consumerConnection;
- protected Session queueProducerSession, queueConsumerSession;
+ protected Session queueProducerSession, queueConsumerSession;
- protected MessageProducer queueProducer;
+ protected MessageProducer queueProducer;
- protected MessageConsumer queueConsumer;
+ protected MessageConsumer queueConsumer;
- // Constructors --------------------------------------------------
+ // Constructors --------------------------------------------------
- // Public --------------------------------------------------------
+ // Public --------------------------------------------------------
- public void setUp() throws Exception
- {
- super.setUp();
+ public void setUp() throws Exception
+ {
+ super.setUp();
- producerConnection = getConnectionFactory().createConnection();
- consumerConnection = getConnectionFactory().createConnection();
+ producerConnection = getConnectionFactory().createConnection();
+ consumerConnection = getConnectionFactory().createConnection();
- queueProducerSession = producerConnection.createSession(false,
- Session.AUTO_ACKNOWLEDGE);
- queueConsumerSession = consumerConnection.createSession(false,
- Session.AUTO_ACKNOWLEDGE);
+ queueProducerSession = producerConnection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
+ queueConsumerSession = consumerConnection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
- queueProducer = queueProducerSession.createProducer(queue1);
- queueConsumer = queueConsumerSession.createConsumer(queue1);
+ queueProducer = queueProducerSession.createProducer(queue1);
+ queueConsumer = queueConsumerSession.createConsumer(queue1);
- consumerConnection.start();
- }
+ consumerConnection.start();
+ }
- public void tearDown() throws Exception
- {
- producerConnection.close();
- consumerConnection.close();
+ public void tearDown() throws Exception
+ {
+ producerConnection.close();
+ consumerConnection.close();
- super.tearDown();
- }
+ super.tearDown();
+ }
- public void testSMBodyReadable() throws Exception
- {
- byte bValue = 123;
- StreamMessage sm = queueProducerSession.createStreamMessage();
- sm.writeByte(bValue);
- sm.setStringProperty("COM_SUN_JMS_TESTNAME",
- "xMessageEOFExceptionQTestforStreamMessage");
- queueProducer.send(sm);
+ public void testSMBodyReadable() throws Exception
+ {
+ byte bValue = 123;
+ StreamMessage sm = queueProducerSession.createStreamMessage();
+ sm.writeByte(bValue);
+ sm.setStringProperty("COM_SUN_JMS_TESTNAME",
"xMessageEOFExceptionQTestforStreamMessage");
+ queueProducer.send(sm);
- StreamMessage received = (StreamMessage) queueConsumer.receive(3000);
- received.readByte();
- }
+ StreamMessage received = (StreamMessage)queueConsumer.receive(3000);
+ received.readByte();
+ }
- public void testBytesMessage() throws Exception
- {
- BytesMessage m = queueProducerSession.createBytesMessage();
+ public void testBytesMessage() throws Exception
+ {
+ BytesMessage m = queueProducerSession.createBytesMessage();
- // some arbitrary values
- boolean myBool = true;
- byte myByte = -111;
- short myShort = 15321;
- int myInt = 0x71ab6c80;
- long myLong = 0x20bf1e3fb6fa31dfL;
- float myFloat = Float.MAX_VALUE - 23465;
- double myDouble = Double.MAX_VALUE - 72387633;
- String myString =
"abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
- log.trace("String is length:" + myString.length());
- char myChar = 'q';
- byte[] myBytes = new byte[] { -23, 114, -126, -12, 74, 87 };
+ // some arbitrary values
+ boolean myBool = true;
+ byte myByte = -111;
+ short myShort = 15321;
+ int myInt = 0x71ab6c80;
+ long myLong = 0x20bf1e3fb6fa31dfL;
+ float myFloat = Float.MAX_VALUE - 23465;
+ double myDouble = Double.MAX_VALUE - 72387633;
+ String myString =
"abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
+ log.trace("String is length:" + myString.length());
+ char myChar = 'q';
+ byte[] myBytes = new byte[] { -23, 114, -126, -12, 74, 87 };
- m.writeBoolean(myBool);
- m.writeByte(myByte);
- m.writeShort(myShort);
- m.writeChar(myChar);
- m.writeInt(myInt);
- m.writeLong(myLong);
- m.writeFloat(myFloat);
- m.writeDouble(myDouble);
- m.writeUTF(myString);
- m.writeBytes(myBytes);
- m.writeBytes(myBytes, 2, 3);
+ m.writeBoolean(myBool);
+ m.writeByte(myByte);
+ m.writeShort(myShort);
+ m.writeChar(myChar);
+ m.writeInt(myInt);
+ m.writeLong(myLong);
+ m.writeFloat(myFloat);
+ m.writeDouble(myDouble);
+ m.writeUTF(myString);
+ m.writeBytes(myBytes);
+ m.writeBytes(myBytes, 2, 3);
- m.writeObject(new Boolean(myBool));
- m.writeObject(new Byte(myByte));
- m.writeObject(new Short(myShort));
- m.writeObject(new Integer(myInt));
- m.writeObject(new Long(myLong));
- m.writeObject(new Float(myFloat));
- m.writeObject(new Double(myDouble));
- m.writeObject(myString);
- m.writeObject(myBytes);
+ m.writeObject(new Boolean(myBool));
+ m.writeObject(new Byte(myByte));
+ m.writeObject(new Short(myShort));
+ m.writeObject(new Integer(myInt));
+ m.writeObject(new Long(myLong));
+ m.writeObject(new Float(myFloat));
+ m.writeObject(new Double(myDouble));
+ m.writeObject(myString);
+ m.writeObject(myBytes);
- try
- {
- m.writeObject(new Object());
- fail();
- } catch (MessageFormatException e)
- {
- // OK
- }
+ try
+ {
+ m.writeObject(new Object());
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ // OK
+ }
- // Reading should not be possible when message is read-write
- try
- {
- m.readBoolean();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readShort();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readChar();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readInt();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readLong();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readFloat();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readDouble();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readUTF();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readUnsignedByte();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.readUnsignedShort();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- byte[] bytes = new byte[333];
- m.readBytes(bytes);
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- byte[] bytes = new byte[333];
- m.readBytes(bytes, 111);
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
- try
- {
- m.getBodyLength();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- // OK
- }
+ // Reading should not be possible when message is read-write
+ try
+ {
+ m.readBoolean();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readShort();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readChar();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readInt();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readLong();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readFloat();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readDouble();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readUTF();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readUnsignedByte();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.readUnsignedShort();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ byte[] bytes = new byte[333];
+ m.readBytes(bytes);
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ byte[] bytes = new byte[333];
+ m.readBytes(bytes, 111);
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m.getBodyLength();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ // OK
+ }
- queueProducer.send(queue1, m);
+ queueProducer.send(queue1, m);
- BytesMessage m2 = (BytesMessage) queueConsumer.receive(2000);
+ BytesMessage m2 = (BytesMessage)queueConsumer.receive(2000);
- assertNotNull(m2);
+ assertNotNull(m2);
- assertEquals(myBool, m2.readBoolean());
- assertEquals(myByte, m2.readByte());
- assertEquals(myShort, m2.readShort());
- assertEquals(myChar, m2.readChar());
- assertEquals(myInt, m2.readInt());
- assertEquals(myLong, m2.readLong());
- assertEquals(myFloat, m2.readFloat(), 0);
- assertEquals(myDouble, m2.readDouble(), 0);
- assertEquals(myString, m2.readUTF());
+ assertEquals(myBool, m2.readBoolean());
+ assertEquals(myByte, m2.readByte());
+ assertEquals(myShort, m2.readShort());
+ assertEquals(myChar, m2.readChar());
+ assertEquals(myInt, m2.readInt());
+ assertEquals(myLong, m2.readLong());
+ assertEquals(myFloat, m2.readFloat(), 0);
+ assertEquals(myDouble, m2.readDouble(), 0);
+ assertEquals(myString, m2.readUTF());
- byte[] bytes = new byte[6];
- int ret = m2.readBytes(bytes);
- assertEquals(6, ret);
+ byte[] bytes = new byte[6];
+ int ret = m2.readBytes(bytes);
+ assertEquals(6, ret);
- assertByteArraysEqual(myBytes, bytes);
+ assertByteArraysEqual(myBytes, bytes);
- byte[] bytes2 = new byte[3];
- ret = m2.readBytes(bytes2);
+ byte[] bytes2 = new byte[3];
+ ret = m2.readBytes(bytes2);
- assertEquals(3, ret);
+ assertEquals(3, ret);
- assertEquals(myBytes[2], bytes2[0]);
- assertEquals(myBytes[3], bytes2[1]);
- assertEquals(myBytes[4], bytes2[2]);
+ assertEquals(myBytes[2], bytes2[0]);
+ assertEquals(myBytes[3], bytes2[1]);
+ assertEquals(myBytes[4], bytes2[2]);
- assertEquals(myBool, m2.readBoolean());
- assertEquals(myByte, m2.readByte());
- assertEquals(myShort, m2.readShort());
- assertEquals(myInt, m2.readInt());
- assertEquals(myLong, m2.readLong());
- assertEquals(myFloat, m2.readFloat(), 0);
- assertEquals(myDouble, m2.readDouble(), 0);
- assertEquals(myString, m2.readUTF());
+ assertEquals(myBool, m2.readBoolean());
+ assertEquals(myByte, m2.readByte());
+ assertEquals(myShort, m2.readShort());
+ assertEquals(myInt, m2.readInt());
+ assertEquals(myLong, m2.readLong());
+ assertEquals(myFloat, m2.readFloat(), 0);
+ assertEquals(myDouble, m2.readDouble(), 0);
+ assertEquals(myString, m2.readUTF());
- bytes = new byte[6];
- ret = m2.readBytes(bytes);
- assertEquals(6, ret);
- assertByteArraysEqual(myBytes, bytes);
+ bytes = new byte[6];
+ ret = m2.readBytes(bytes);
+ assertEquals(6, ret);
+ assertByteArraysEqual(myBytes, bytes);
- ret = m2.readBytes(bytes);
- assertEquals(-1, ret);
+ ret = m2.readBytes(bytes);
+ assertEquals(-1, ret);
- // Try and read past the end of the stream
- try
- {
- m2.readBoolean();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ // Try and read past the end of the stream
+ try
+ {
+ m2.readBoolean();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readByte();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readByte();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readChar();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readChar();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readDouble();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readDouble();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readFloat();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readFloat();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readInt();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readInt();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readLong();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readLong();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readShort();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readShort();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readUnsignedByte();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readUnsignedByte();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readUnsignedShort();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readUnsignedShort();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- try
- {
- m2.readUTF();
- fail();
- } catch (MessageEOFException e)
- {
- // OK
- }
+ try
+ {
+ m2.readUTF();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ // OK
+ }
- // Message should not be writable in read-only mode
- try
- {
- m2.writeBoolean(myBool);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeByte(myByte);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeShort(myShort);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeChar(myChar);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
+ // Message should not be writable in read-only mode
+ try
+ {
+ m2.writeBoolean(myBool);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeByte(myByte);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeShort(myShort);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeChar(myChar);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
- try
- {
- m2.writeInt(myInt);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeLong(myLong);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeFloat(myFloat);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeDouble(myDouble);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
- try
- {
- m2.writeUTF(myString);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
+ try
+ {
+ m2.writeInt(myInt);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeLong(myLong);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeFloat(myFloat);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeDouble(myDouble);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
+ try
+ {
+ m2.writeUTF(myString);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
- try
- {
- m2.writeBytes(myBytes);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
+ try
+ {
+ m2.writeBytes(myBytes);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
- try
- {
- m2.writeObject(myString);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- // OK
- }
+ try
+ {
+ m2.writeObject(myString);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ // OK
+ }
- long bodyLength = m2.getBodyLength();
+ long bodyLength = m2.getBodyLength();
- assertEquals(161, bodyLength);
+ assertEquals(161, bodyLength);
- m2.reset();
+ m2.reset();
- // test the unsigned reads
+ // test the unsigned reads
- m2.readBoolean();
- int unsignedByte = m2.readUnsignedByte();
+ m2.readBoolean();
+ int unsignedByte = m2.readUnsignedByte();
- assertEquals((int) (myByte & 0xFF), unsignedByte);
+ assertEquals((int)(myByte & 0xFF), unsignedByte);
- int unsignedShort = m2.readUnsignedShort();
+ int unsignedShort = m2.readUnsignedShort();
- assertEquals((int) (myShort & 0xFFFF), unsignedShort);
+ assertEquals((int)(myShort & 0xFFFF), unsignedShort);
- m2.clearBody();
+ m2.clearBody();
- try
- {
- m2.getBodyLength();
- fail();
- } catch (MessageNotReadableException e)
- {
- // OK
- }
+ try
+ {
+ m2.getBodyLength();
+ fail();
+ }
+ catch (MessageNotReadableException e)
+ {
+ // OK
+ }
- m2.reset();
+ m2.reset();
- assertEquals(0, m2.getBodyLength());
+ assertEquals(0, m2.getBodyLength());
- // Test that changing the received message doesn't affect the sent message
- m.reset();
- assertEquals(161, m.getBodyLength());
+ // Test that changing the received message doesn't affect the sent message
+ m.reset();
+ assertEquals(161, m.getBodyLength());
- // Should be diffent object instances after sending *even* if in same JVM
- assertFalse(m == m2);
+ // Should be diffent object instances after sending *even* if in same JVM
+ assertFalse(m == m2);
- }
+ }
- public void testMapMessage() throws Exception
- {
- MapMessage m1 = queueProducerSession.createMapMessage();
+ public void testMapMessage() throws Exception
+ {
+ MapMessage m1 = queueProducerSession.createMapMessage();
- // Some arbitrary values
- boolean myBool = true;
- byte myByte = 13;
- short myShort = 15321;
- int myInt = 0x71ab6c80;
- long myLong = 0x20bf1e3fb6fa31dfL;
- float myFloat = Float.MAX_VALUE - 23465;
- double myDouble = Double.MAX_VALUE - 72387633;
- String myString =
"abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
+ // Some arbitrary values
+ boolean myBool = true;
+ byte myByte = 13;
+ short myShort = 15321;
+ int myInt = 0x71ab6c80;
+ long myLong = 0x20bf1e3fb6fa31dfL;
+ float myFloat = Float.MAX_VALUE - 23465;
+ double myDouble = Double.MAX_VALUE - 72387633;
+ String myString =
"abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
- m1.setBoolean("myBool", myBool);
- m1.setByte("myByte", myByte);
- m1.setShort("myShort", myShort);
- m1.setInt("myInt", myInt);
- m1.setLong("myLong", myLong);
- m1.setFloat("myFloat", myFloat);
- m1.setDouble("myDouble", myDouble);
- m1.setString("myString", myString);
+ m1.setBoolean("myBool", myBool);
+ m1.setByte("myByte", myByte);
+ m1.setShort("myShort", myShort);
+ m1.setInt("myInt", myInt);
+ m1.setLong("myLong", myLong);
+ m1.setFloat("myFloat", myFloat);
+ m1.setDouble("myDouble", myDouble);
+ m1.setString("myString", myString);
- m1.setObject("myBool", new Boolean(myBool));
- m1.setObject("myByte", new Byte(myByte));
- m1.setObject("myShort", new Short(myShort));
- m1.setObject("myInt", new Integer(myInt));
- m1.setObject("myLong", new Long(myLong));
- m1.setObject("myFloat", new Float(myFloat));
- m1.setObject("myDouble", new Double(myDouble));
- m1.setObject("myString", myString);
+ m1.setObject("myBool", new Boolean(myBool));
+ m1.setObject("myByte", new Byte(myByte));
+ m1.setObject("myShort", new Short(myShort));
+ m1.setObject("myInt", new Integer(myInt));
+ m1.setObject("myLong", new Long(myLong));
+ m1.setObject("myFloat", new Float(myFloat));
+ m1.setObject("myDouble", new Double(myDouble));
+ m1.setObject("myString", myString);
- try
- {
- m1.setObject("myIllegal", new Object());
- fail();
- } catch (javax.jms.MessageFormatException e)
- {
- }
+ try
+ {
+ m1.setObject("myIllegal", new Object());
+ fail();
+ }
+ catch (javax.jms.MessageFormatException e)
+ {
+ }
- queueProducer.send(queue1, m1);
+ queueProducer.send(queue1, m1);
- MapMessage m2 = (MapMessage) queueConsumer.receive(2000);
+ MapMessage m2 = (MapMessage)queueConsumer.receive(2000);
- assertNotNull(m2);
+ assertNotNull(m2);
- assertEquals(myBool, m2.getBoolean("myBool"));
- assertEquals(myByte, m2.getByte("myByte"));
- assertEquals(myShort, m2.getShort("myShort"));
- assertEquals(myInt, m2.getInt("myInt"));
- assertEquals(myLong, m2.getLong("myLong"));
- assertEquals(myFloat, m2.getFloat("myFloat"), 0);
- assertEquals(myDouble, m2.getDouble("myDouble"), 0);
- assertEquals(myString, m2.getString("myString"));
+ assertEquals(myBool, m2.getBoolean("myBool"));
+ assertEquals(myByte, m2.getByte("myByte"));
+ assertEquals(myShort, m2.getShort("myShort"));
+ assertEquals(myInt, m2.getInt("myInt"));
+ assertEquals(myLong, m2.getLong("myLong"));
+ assertEquals(myFloat, m2.getFloat("myFloat"), 0);
+ assertEquals(myDouble, m2.getDouble("myDouble"), 0);
+ assertEquals(myString, m2.getString("myString"));
- // Properties should now be read-only
- try
- {
- m2.setBoolean("myBool", myBool);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ // Properties should now be read-only
+ try
+ {
+ m2.setBoolean("myBool", myBool);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setByte("myByte", myByte);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setByte("myByte", myByte);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setShort("myShort", myShort);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setShort("myShort", myShort);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setInt("myInt", myInt);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setInt("myInt", myInt);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setLong("myLong", myLong);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setLong("myLong", myLong);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setFloat("myFloat", myFloat);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setFloat("myFloat", myFloat);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setDouble("myDouble", myDouble);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setDouble("myDouble", myDouble);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.setString("myString", myString);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.setString("myString", myString);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- assertTrue(m2.itemExists("myBool"));
- assertTrue(m2.itemExists("myByte"));
- assertTrue(m2.itemExists("myShort"));
- assertTrue(m2.itemExists("myInt"));
- assertTrue(m2.itemExists("myLong"));
- assertTrue(m2.itemExists("myFloat"));
- assertTrue(m2.itemExists("myDouble"));
- assertTrue(m2.itemExists("myString"));
+ assertTrue(m2.itemExists("myBool"));
+ assertTrue(m2.itemExists("myByte"));
+ assertTrue(m2.itemExists("myShort"));
+ assertTrue(m2.itemExists("myInt"));
+ assertTrue(m2.itemExists("myLong"));
+ assertTrue(m2.itemExists("myFloat"));
+ assertTrue(m2.itemExists("myDouble"));
+ assertTrue(m2.itemExists("myString"));
- assertFalse(m2.itemExists("sausages"));
+ assertFalse(m2.itemExists("sausages"));
- HashSet itemNames = new HashSet();
- Enumeration en = m2.getMapNames();
- while (en.hasMoreElements())
- {
- String propName = (String) en.nextElement();
- itemNames.add(propName);
- }
+ HashSet itemNames = new HashSet();
+ Enumeration en = m2.getMapNames();
+ while (en.hasMoreElements())
+ {
+ String propName = (String)en.nextElement();
+ itemNames.add(propName);
+ }
- assertEquals(8, itemNames.size());
+ assertEquals(8, itemNames.size());
- assertTrue(itemNames.contains("myBool"));
- assertTrue(itemNames.contains("myByte"));
- assertTrue(itemNames.contains("myShort"));
- assertTrue(itemNames.contains("myInt"));
- assertTrue(itemNames.contains("myLong"));
- assertTrue(itemNames.contains("myFloat"));
- assertTrue(itemNames.contains("myDouble"));
- assertTrue(itemNames.contains("myString"));
+ assertTrue(itemNames.contains("myBool"));
+ assertTrue(itemNames.contains("myByte"));
+ assertTrue(itemNames.contains("myShort"));
+ assertTrue(itemNames.contains("myInt"));
+ assertTrue(itemNames.contains("myLong"));
+ assertTrue(itemNames.contains("myFloat"));
+ assertTrue(itemNames.contains("myDouble"));
+ assertTrue(itemNames.contains("myString"));
- // Check property conversions
+ // Check property conversions
- // Boolean property can be read as String but not anything else
+ // Boolean property can be read as String but not anything else
- assertEquals(String.valueOf(myBool), m2.getString("myBool"));
+ assertEquals(String.valueOf(myBool), m2.getString("myBool"));
- try
- {
- m2.getByte("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getShort("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getShort("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getInt("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getInt("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getLong("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getLong("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getDouble("myBool");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getDouble("myBool");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // byte item can be read as short, int, long or String
+ // byte item can be read as short, int, long or String
- assertEquals((short) myByte, m2.getShort("myByte"));
- assertEquals((int) myByte, m2.getInt("myByte"));
- assertEquals((long) myByte, m2.getLong("myByte"));
- assertEquals(String.valueOf(myByte), m2.getString("myByte"));
+ assertEquals((short)myByte, m2.getShort("myByte"));
+ assertEquals((int)myByte, m2.getInt("myByte"));
+ assertEquals((long)myByte, m2.getLong("myByte"));
+ assertEquals(String.valueOf(myByte), m2.getString("myByte"));
- try
- {
- m2.getBoolean("myByte");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myByte");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myByte");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myByte");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getDouble("myByte");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getDouble("myByte");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // short item can be read as int, long or String
+ // short item can be read as int, long or String
- assertEquals((int) myShort, m2.getInt("myShort"));
- assertEquals((long) myShort, m2.getLong("myShort"));
- assertEquals(String.valueOf(myShort), m2.getString("myShort"));
+ assertEquals((int)myShort, m2.getInt("myShort"));
+ assertEquals((long)myShort, m2.getLong("myShort"));
+ assertEquals(String.valueOf(myShort), m2.getString("myShort"));
- try
- {
- m2.getByte("myShort");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myShort");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getBoolean("myShort");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myShort");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myShort");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myShort");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getDouble("myShort");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getDouble("myShort");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // int item can be read as long or String
+ // int item can be read as long or String
- assertEquals((long) myInt, m2.getLong("myInt"));
- assertEquals(String.valueOf(myInt), m2.getString("myInt"));
+ assertEquals((long)myInt, m2.getLong("myInt"));
+ assertEquals(String.valueOf(myInt), m2.getString("myInt"));
- try
- {
- m2.getShort("myInt");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getShort("myInt");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getByte("myInt");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myInt");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getBoolean("myInt");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myInt");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myInt");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myInt");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getDouble("myInt");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getDouble("myInt");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // long item can be read as String
+ // long item can be read as String
- assertEquals(String.valueOf(myLong), m2.getString("myLong"));
+ assertEquals(String.valueOf(myLong), m2.getString("myLong"));
- try
- {
- m2.getInt("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getInt("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getShort("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getShort("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getByte("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getBoolean("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getDouble("myLong");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getDouble("myLong");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // float can be read as double or String
+ // float can be read as double or String
- assertEquals(String.valueOf(myFloat), m2.getString("myFloat"));
- assertEquals((double) myFloat, m2.getDouble("myFloat"), 0);
+ assertEquals(String.valueOf(myFloat), m2.getString("myFloat"));
+ assertEquals((double)myFloat, m2.getDouble("myFloat"), 0);
- try
- {
- m2.getInt("myFloat");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getInt("myFloat");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getShort("myFloat");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getShort("myFloat");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getLong("myFloat");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getLong("myFloat");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getByte("myFloat");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myFloat");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getBoolean("myFloat");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myFloat");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- // double can be read as String
+ // double can be read as String
- assertEquals(String.valueOf(myDouble), m2.getString("myDouble"));
+ assertEquals(String.valueOf(myDouble), m2.getString("myDouble"));
- try
- {
- m2.getFloat("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getInt("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getInt("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getShort("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getShort("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getByte("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getByte("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getBoolean("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getBoolean("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- try
- {
- m2.getFloat("myDouble");
- fail();
- } catch (MessageFormatException e)
- {
- }
+ try
+ {
+ m2.getFloat("myDouble");
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- m2.clearBody();
+ m2.clearBody();
- assertFalse(m2.getMapNames().hasMoreElements());
+ assertFalse(m2.getMapNames().hasMoreElements());
- // Test String -> Numeric and bool conversions
- MapMessage m3 = (MapMessage) queueProducerSession.createMapMessage();
+ // Test String -> Numeric and bool conversions
+ MapMessage m3 = (MapMessage)queueProducerSession.createMapMessage();
- m3.setString("myBool", String.valueOf(myBool));
- m3.setString("myByte", String.valueOf(myByte));
- m3.setString("myShort", String.valueOf(myShort));
- m3.setString("myInt", String.valueOf(myInt));
- m3.setString("myLong", String.valueOf(myLong));
- m3.setString("myFloat", String.valueOf(myFloat));
- m3.setString("myDouble", String.valueOf(myDouble));
- m3.setString("myIllegal", "xyz123");
+ m3.setString("myBool", String.valueOf(myBool));
+ m3.setString("myByte", String.valueOf(myByte));
+ m3.setString("myShort", String.valueOf(myShort));
+ m3.setString("myInt", String.valueOf(myInt));
+ m3.setString("myLong", String.valueOf(myLong));
+ m3.setString("myFloat", String.valueOf(myFloat));
+ m3.setString("myDouble", String.valueOf(myDouble));
+ m3.setString("myIllegal", "xyz123");
- assertEquals(myBool, m3.getBoolean("myBool"));
- assertEquals(myByte, m3.getByte("myByte"));
- assertEquals(myShort, m3.getShort("myShort"));
- assertEquals(myInt, m3.getInt("myInt"));
- assertEquals(myLong, m3.getLong("myLong"));
- assertEquals(myFloat, m3.getFloat("myFloat"), 0);
- assertEquals(myDouble, m3.getDouble("myDouble"), 0);
+ assertEquals(myBool, m3.getBoolean("myBool"));
+ assertEquals(myByte, m3.getByte("myByte"));
+ assertEquals(myShort, m3.getShort("myShort"));
+ assertEquals(myInt, m3.getInt("myInt"));
+ assertEquals(myLong, m3.getLong("myLong"));
+ assertEquals(myFloat, m3.getFloat("myFloat"), 0);
+ assertEquals(myDouble, m3.getDouble("myDouble"), 0);
- m3.getBoolean("myIllegal");
+ m3.getBoolean("myIllegal");
- try
- {
- m3.getByte("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
- try
- {
- m3.getShort("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
- try
- {
- m3.getInt("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
- try
- {
- m3.getLong("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
- try
- {
- m3.getFloat("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
- try
- {
- m3.getDouble("myIllegal");
- fail();
- } catch (NumberFormatException e)
- {
- }
+ try
+ {
+ m3.getByte("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ try
+ {
+ m3.getShort("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ try
+ {
+ m3.getInt("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ try
+ {
+ m3.getLong("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ try
+ {
+ m3.getFloat("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ try
+ {
+ m3.getDouble("myIllegal");
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
- }
+ }
- static class TestSerializable implements Serializable
- {
- private static final long serialVersionUID = -8641359255228705573L;
+ static class TestSerializable implements Serializable
+ {
+ private static final long serialVersionUID = -8641359255228705573L;
- String str;
- }
+ String str;
+ }
- public void testObjectMessage() throws Exception
- {
- TestSerializable obj = new TestSerializable();
+ public void testObjectMessage() throws Exception
+ {
+ TestSerializable obj = new TestSerializable();
- obj.str = "abcdefg";
+ obj.str = "abcdefg";
- ObjectMessage m1 = queueProducerSession.createObjectMessage(obj);
+ ObjectMessage m1 = queueProducerSession.createObjectMessage(obj);
- queueProducer.send(queue1, m1);
+ queueProducer.send(queue1, m1);
- ObjectMessage m2 = (ObjectMessage) queueConsumer.receive(2000);
+ ObjectMessage m2 = (ObjectMessage)queueConsumer.receive(2000);
- assertNotNull(m2);
+ assertNotNull(m2);
- TestSerializable obj2 = (TestSerializable) m2.getObject();
+ TestSerializable obj2 = (TestSerializable)m2.getObject();
- assertEquals(obj.str, obj2.str);
+ assertEquals(obj.str, obj2.str);
- ObjectMessage m3 = queueProducerSession.createObjectMessage();
+ ObjectMessage m3 = queueProducerSession.createObjectMessage();
- m3.setObject(obj);
-
- queueProducer.send(queue1, m3);
-
- obj.str = "xyz123";
+ m3.setObject(obj);
- ObjectMessage m4 = (ObjectMessage) queueConsumer.receive(2000);
+ queueProducer.send(queue1, m3);
- assertNotNull(m4);
+ obj.str = "xyz123";
- TestSerializable obj3 = (TestSerializable) m4.getObject();
+ ObjectMessage m4 = (ObjectMessage)queueConsumer.receive(2000);
- assertEquals("abcdefg", obj3.str);
+ assertNotNull(m4);
- try
- {
- m4.setObject(obj);
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ TestSerializable obj3 = (TestSerializable)m4.getObject();
- m4.clearBody();
+ assertEquals("abcdefg", obj3.str);
- m4.setObject(obj);
+ try
+ {
+ m4.setObject(obj);
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- TestSerializable obj4 = (TestSerializable) m4.getObject();
+ m4.clearBody();
- assertNotNull(obj4);
+ m4.setObject(obj);
- }
+ TestSerializable obj4 = (TestSerializable)m4.getObject();
- public void testStreamMessage() throws Exception
- {
- StreamMessage m = queueProducerSession.createStreamMessage();
+ assertNotNull(obj4);
- // Some arbitrary values
- boolean myBool = true;
- byte myByte = -111;
- short myShort = 15321;
- int myInt = 0x71ab6c80;
- long myLong = 0x20bf1e3fb6fa31dfL;
- float myFloat = Float.MAX_VALUE - 23465;
- double myDouble = Double.MAX_VALUE - 72387633;
- String myString =
"abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
- char myChar = 'q';
- byte[] myBytes = new byte[] { -23, 114, -126, -12, 74, 87 };
+ }
- m.writeBoolean(myBool);
- m.writeByte(myByte);
- m.writeShort(myShort);
- m.writeChar(myChar);
- m.writeInt(myInt);
- m.writeLong(myLong);
- m.writeFloat(myFloat);
- m.writeDouble(myDouble);
- m.writeString(myString);
- m.writeBytes(myBytes);
- m.writeBytes(myBytes, 2, 3);
+ public void testStreamMessage() throws Exception
+ {
+ StreamMessage m = queueProducerSession.createStreamMessage();
- m.writeObject(new Boolean(myBool));
- m.writeObject(new Byte(myByte));
- m.writeObject(new Short(myShort));
- m.writeObject(new Integer(myInt));
- m.writeObject(new Long(myLong));
- m.writeObject(new Float(myFloat));
- m.writeObject(new Double(myDouble));
- m.writeObject(myString);
- m.writeObject(myBytes);
+ // Some arbitrary values
+ boolean myBool = true;
+ byte myByte = -111;
+ short myShort = 15321;
+ int myInt = 0x71ab6c80;
+ long myLong = 0x20bf1e3fb6fa31dfL;
+ float myFloat = Float.MAX_VALUE - 23465;
+ double myDouble = Double.MAX_VALUE - 72387633;
+ String myString =
"abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
+ char myChar = 'q';
+ byte[] myBytes = new byte[] { -23, 114, -126, -12, 74, 87 };
- try
- {
- m.writeObject(new Object());
- fail();
- } catch (MessageFormatException e)
- {
- }
+ m.writeBoolean(myBool);
+ m.writeByte(myByte);
+ m.writeShort(myShort);
+ m.writeChar(myChar);
+ m.writeInt(myInt);
+ m.writeLong(myLong);
+ m.writeFloat(myFloat);
+ m.writeDouble(myDouble);
+ m.writeString(myString);
+ m.writeBytes(myBytes);
+ m.writeBytes(myBytes, 2, 3);
- // Reading should not be possible when message is read-write
- try
- {
- m.readBoolean();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readShort();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readChar();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readInt();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readLong();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readFloat();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- m.readDouble();
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
- try
- {
- byte[] bytes = new byte[333];
- m.readBytes(bytes);
- fail();
- } catch (javax.jms.MessageNotReadableException e)
- {
- }
+ m.writeObject(new Boolean(myBool));
+ m.writeObject(new Byte(myByte));
+ m.writeObject(new Short(myShort));
+ m.writeObject(new Integer(myInt));
+ m.writeObject(new Long(myLong));
+ m.writeObject(new Float(myFloat));
+ m.writeObject(new Double(myDouble));
+ m.writeObject(myString);
+ m.writeObject(myBytes);
- queueProducer.send(queue1, m);
+ try
+ {
+ m.writeObject(new Object());
+ fail();
+ }
+ catch (MessageFormatException e)
+ {
+ }
- StreamMessage m2 = (StreamMessage) queueConsumer.receive(2000);
+ // Reading should not be possible when message is read-write
+ try
+ {
+ m.readBoolean();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readShort();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readChar();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readInt();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readLong();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readFloat();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ m.readDouble();
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
+ try
+ {
+ byte[] bytes = new byte[333];
+ m.readBytes(bytes);
+ fail();
+ }
+ catch (javax.jms.MessageNotReadableException e)
+ {
+ }
- assertEquals(myBool, m2.readBoolean());
- assertEquals(myByte, m2.readByte());
- assertEquals(myShort, m2.readShort());
- assertEquals(myChar, m2.readChar());
- assertEquals(myInt, m2.readInt());
- assertEquals(myLong, m2.readLong());
- assertEquals(myFloat, m2.readFloat(), 0);
- assertEquals(myDouble, m2.readDouble(), 0);
- assertEquals(myString, m2.readString());
+ queueProducer.send(queue1, m);
- byte[] bytes = new byte[6];
- int ret = m2.readBytes(bytes);
- assertEquals(6, ret);
+ StreamMessage m2 = (StreamMessage)queueConsumer.receive(2000);
- assertByteArraysEqual(myBytes, bytes);
+ assertEquals(myBool, m2.readBoolean());
+ assertEquals(myByte, m2.readByte());
+ assertEquals(myShort, m2.readShort());
+ assertEquals(myChar, m2.readChar());
+ assertEquals(myInt, m2.readInt());
+ assertEquals(myLong, m2.readLong());
+ assertEquals(myFloat, m2.readFloat(), 0);
+ assertEquals(myDouble, m2.readDouble(), 0);
+ assertEquals(myString, m2.readString());
- ret = m2.readBytes(bytes);
- assertEquals(-1, ret);
+ byte[] bytes = new byte[6];
+ int ret = m2.readBytes(bytes);
+ assertEquals(6, ret);
- byte[] bytes2 = new byte[3];
- ret = m2.readBytes(bytes2);
+ assertByteArraysEqual(myBytes, bytes);
- assertEquals(3, ret);
+ ret = m2.readBytes(bytes);
+ assertEquals(-1, ret);
- assertEquals(myBytes[2], bytes2[0]);
- assertEquals(myBytes[3], bytes2[1]);
- assertEquals(myBytes[4], bytes2[2]);
+ byte[] bytes2 = new byte[3];
+ ret = m2.readBytes(bytes2);
- ret = m2.readBytes(bytes2);
- assertEquals(-1, ret);
+ assertEquals(3, ret);
- assertEquals(myBool, m2.readBoolean());
- assertEquals(myByte, m2.readByte());
- assertEquals(myShort, m2.readShort());
- assertEquals(myInt, m2.readInt());
- assertEquals(myLong, m2.readLong());
- assertEquals(myFloat, m2.readFloat(), 0);
- assertEquals(myDouble, m2.readDouble(), 0);
- assertEquals(myString, m2.readString());
+ assertEquals(myBytes[2], bytes2[0]);
+ assertEquals(myBytes[3], bytes2[1]);
+ assertEquals(myBytes[4], bytes2[2]);
- bytes = new byte[6];
- ret = m2.readBytes(bytes);
- assertEquals(6, ret);
- assertByteArraysEqual(myBytes, bytes);
+ ret = m2.readBytes(bytes2);
+ assertEquals(-1, ret);
- ret = m2.readBytes(bytes);
- assertEquals(-1, ret);
+ assertEquals(myBool, m2.readBoolean());
+ assertEquals(myByte, m2.readByte());
+ assertEquals(myShort, m2.readShort());
+ assertEquals(myInt, m2.readInt());
+ assertEquals(myLong, m2.readLong());
+ assertEquals(myFloat, m2.readFloat(), 0);
+ assertEquals(myDouble, m2.readDouble(), 0);
+ assertEquals(myString, m2.readString());
- // Try and read past the end of the stream
- try
- {
- m2.readBoolean();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ bytes = new byte[6];
+ ret = m2.readBytes(bytes);
+ assertEquals(6, ret);
+ assertByteArraysEqual(myBytes, bytes);
- try
- {
- m2.readByte();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ ret = m2.readBytes(bytes);
+ assertEquals(-1, ret);
- try
- {
- m2.readChar();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ // Try and read past the end of the stream
+ try
+ {
+ m2.readBoolean();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.readDouble();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ try
+ {
+ m2.readByte();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.readFloat();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ try
+ {
+ m2.readChar();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.readInt();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ try
+ {
+ m2.readDouble();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.readLong();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ try
+ {
+ m2.readFloat();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.readShort();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ try
+ {
+ m2.readInt();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- // Message should not be writable in read-only mode
- try
- {
- m2.writeBoolean(myBool);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeByte(myByte);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeShort(myShort);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeChar(myChar);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.readLong();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.writeInt(myInt);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeLong(myLong);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeFloat(myFloat);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
- try
- {
- m2.writeDouble(myDouble);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.readShort();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- try
- {
- m2.writeBytes(myBytes);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
+ // Message should not be writable in read-only mode
+ try
+ {
+ m2.writeBoolean(myBool);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeByte(myByte);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeShort(myShort);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeChar(myChar);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
- try
- {
- m2.writeObject(myString);
- fail();
- } catch (javax.jms.MessageNotWriteableException e)
- {
- }
+ try
+ {
+ m2.writeInt(myInt);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeLong(myLong);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeFloat(myFloat);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
+ try
+ {
+ m2.writeDouble(myDouble);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
- m2.reset();
+ try
+ {
+ m2.writeBytes(myBytes);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
- // check we go back to the beginning
- assertEquals(myBool, m2.readBoolean());
- assertEquals(myByte, m2.readByte());
- assertEquals(myShort, m2.readShort());
- assertEquals(myChar, m2.readChar());
- assertEquals(myInt, m2.readInt());
- assertEquals(myLong, m2.readLong());
- assertEquals(myFloat, m2.readFloat(), 0);
- assertEquals(myDouble, m2.readDouble(), 0);
- assertEquals(myString, m2.readString());
+ try
+ {
+ m2.writeObject(myString);
+ fail();
+ }
+ catch (javax.jms.MessageNotWriteableException e)
+ {
+ }
- m2.clearBody();
+ m2.reset();
- try
- {
- // Should now be write only
- m2.readBoolean();
- fail();
- } catch (MessageNotReadableException e)
- {
- }
+ // check we go back to the beginning
+ assertEquals(myBool, m2.readBoolean());
+ assertEquals(myByte, m2.readByte());
+ assertEquals(myShort, m2.readShort());
+ assertEquals(myChar, m2.readChar());
+ assertEquals(myInt, m2.readInt());
+ assertEquals(myLong, m2.readLong());
+ assertEquals(myFloat, m2.readFloat(), 0);
+ assertEquals(myDouble, m2.readDouble(), 0);
+ assertEquals(myString, m2.readString());
- m2.writeBoolean(myBool);
+ m2.clearBody();
- m2.reset();
+ try
+ {
+ // Should now be write only
+ m2.readBoolean();
+ fail();
+ }
+ catch (MessageNotReadableException e)
+ {
+ }
- assertEquals(myBool, m2.readBoolean());
- try
- {
- m2.readBoolean();
- fail();
- } catch (MessageEOFException e)
- {
- }
+ m2.writeBoolean(myBool);
- // Test that changing the received message doesn't affect the sent message
- m.reset();
- assertEquals(myBool, m.readBoolean());
- assertEquals(myByte, m.readByte());
- assertEquals(myShort, m.readShort());
- assertEquals(myChar, m.readChar());
- assertEquals(myInt, m.readInt());
- assertEquals(myLong, m.readLong());
- assertEquals(myFloat, m.readFloat(), 0);
- assertEquals(myDouble, m.readDouble(), 0);
- assertEquals(myString, m.readString());
+ m2.reset();
- // Should be diffent object instances after sending *even* if in same JVM
- assertFalse(m == m2);
- }
+ assertEquals(myBool, m2.readBoolean());
+ try
+ {
+ m2.readBoolean();
+ fail();
+ }
+ catch (MessageEOFException e)
+ {
+ }
- public void testTextMessage() throws Exception
- {
- TextMessage m = queueProducerSession.createTextMessage();
+ // Test that changing the received message doesn't affect the sent message
+ m.reset();
+ assertEquals(myBool, m.readBoolean());
+ assertEquals(myByte, m.readByte());
+ assertEquals(myShort, m.readShort());
+ assertEquals(myChar, m.readChar());
+ assertEquals(myInt, m.readInt());
+ assertEquals(myLong, m.readLong());
+ assertEquals(myFloat, m.readFloat(), 0);
+ assertEquals(myDouble, m.readDouble(), 0);
+ assertEquals(myString, m.readString());
- // Arbitrary string with some Chinese characters to make sure UTF encoding
- // is ok
- String myString =
"wwiuhdiuwhdwuhdwuhduqwhdiuwhdiuhwed8u29837482787\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
+ // Should be diffent object instances after sending *even* if in same JVM
+ assertFalse(m == m2);
+ }
- m.setText(myString);
+ public void testTextMessage() throws Exception
+ {
+ TextMessage m = queueProducerSession.createTextMessage();
- queueProducer.send(queue1, m);
+ // Arbitrary string with some Chinese characters to make sure UTF encoding
+ // is ok
+ String myString =
"wwiuhdiuwhdwuhdwuhduqwhdiuwhdiuhwed8u29837482787\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
- TextMessage m2 = (TextMessage) queueConsumer.receive(2000);
+ m.setText(myString);
- assertEquals(myString, m2.getText());
+ queueProducer.send(queue1, m);
- m = queueProducerSession.createTextMessage(myString);
- queueProducer.send(queue1, m);
+ TextMessage m2 = (TextMessage)queueConsumer.receive(2000);
- m2 = (TextMessage) queueConsumer.receive(2000);
+ assertEquals(myString, m2.getText());
- assertEquals(myString, m2.getText());
+ m = queueProducerSession.createTextMessage(myString);
+ queueProducer.send(queue1, m);
- try
- {
- m2.setText("Should be read-only");
- fail();
- } catch (MessageNotWriteableException e)
- {
- }
+ m2 = (TextMessage)queueConsumer.receive(2000);
- m2.clearBody();
- assertNull(m2.getText());
- m2.setText("Now it is read-write");
- }
+ assertEquals(myString, m2.getText());
- // Package protected ---------------------------------------------
+ try
+ {
+ m2.setText("Should be read-only");
+ fail();
+ }
+ catch (MessageNotWriteableException e)
+ {
+ }
- // Protected -----------------------------------------------------
+ m2.clearBody();
+ assertNull(m2.getText());
+ m2.setText("Now it is read-write");
+ }
- // Private -------------------------------------------------------
+ // Package protected ---------------------------------------------
- private void assertByteArraysEqual(byte[] bytes1, byte[] bytes2)
- {
- if (bytes1 == null | bytes2 == null)
- {
- fail();
- }
+ // Protected -----------------------------------------------------
- if (bytes1.length != bytes2.length)
- {
- fail();
- }
+ // Private -------------------------------------------------------
- for (int i = 0; i < bytes1.length; i++)
- {
- assertEquals(bytes1[i], bytes2[i]);
- }
+ private void assertByteArraysEqual(byte[] bytes1, byte[] bytes2)
+ {
+ if (bytes1 == null | bytes2 == null)
+ {
+ fail();
+ }
- }
+ if (bytes1.length != bytes2.length)
+ {
+ fail();
+ }
- // Inner classes -------------------------------------------------
+ for (int i = 0; i < bytes1.length; i++)
+ {
+ assertEquals(bytes1[i], bytes2[i]);
+ }
+ }
+
+ // Inner classes -------------------------------------------------
+
}
Modified:
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java
===================================================================
---
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -675,7 +675,8 @@
HornetQBuffer body = HornetQChannelBuffers.buffer(1024);
ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, body);
ClientSession session = new FakeSession(clientMessage);
- HornetQMessage jbossMessage = new HornetQMessage();
+ HornetQMessage jbossMessage = HornetQMessage.createMessage(clientMessage,
session);
+ jbossMessage.clearProperties();
configureMessage(jbossMessage);
Deleted:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/EncodeSizeTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/EncodeSizeTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/EncodeSizeTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -1,137 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.tests.integration;
-
-import org.hornetq.core.buffers.HornetQChannelBuffers;
-import org.hornetq.core.client.ClientMessage;
-import org.hornetq.core.client.impl.ClientMessageImpl;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.impl.wireformat.SessionSendLargeMessage;
-import org.hornetq.core.remoting.impl.wireformat.SessionSendMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.core.server.ServerMessage;
-import org.hornetq.core.server.impl.ServerMessageImpl;
-import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.tests.util.UnitTestCase;
-
-/**
- * A EncodeSizeTest
- *
- * For flow control, it's crucial that encode sizes on client and server are the
same
- *
- * @author Tim Fox
- *
- *
- */
-public class EncodeSizeTest extends UnitTestCase
-{
- private static final Logger log = Logger.getLogger(EncodeSizeTest.class);
-
- public void testMessageEncodeSize() throws Exception
- {
- for (int i = 0; i < 10; i++)
- {
- ClientMessage clientMessage = new ClientMessageImpl(0);
-
- clientMessage.putIntProperty(RandomUtil.randomString(),
RandomUtil.randomInt());
- clientMessage.putBooleanProperty(RandomUtil.randomString(),
RandomUtil.randomBoolean());
- clientMessage.putByteProperty(RandomUtil.randomString(),
RandomUtil.randomByte());
- clientMessage.putBytesProperty(RandomUtil.randomString(),
RandomUtil.randomBytes(125));
- clientMessage.putDoubleProperty(RandomUtil.randomString(),
RandomUtil.randomDouble());
- clientMessage.putFloatProperty(RandomUtil.randomString(),
RandomUtil.randomFloat());
- clientMessage.putLongProperty(RandomUtil.randomString(),
RandomUtil.randomLong());
- clientMessage.putShortProperty(RandomUtil.randomString(),
RandomUtil.randomShort());
- clientMessage.putStringProperty(RandomUtil.randomString(),
RandomUtil.randomString());
-
- clientMessage.setDestination(RandomUtil.randomSimpleString());
-
- byte[] bytes = RandomUtil.randomBytes(1000);
-
- HornetQBuffer body = HornetQChannelBuffers.dynamicBuffer(bytes);
-
- clientMessage.setBuffer(body);
-
- int clientEncodeSize = clientMessage.getEncodeSize();
-
- HornetQBuffer buffer = HornetQChannelBuffers.dynamicBuffer(clientEncodeSize);
-
- clientMessage.encode(buffer);
-
- int wireSize = buffer.writerIndex();
-
- assertEquals(clientEncodeSize, wireSize);
-
- ServerMessage serverMessage = new ServerMessageImpl();
-
- serverMessage.decodeHeadersAndProperties(buffer);
-
- int serverEncodeSize = serverMessage.getEncodeSize();
-
- assertEquals(wireSize, serverEncodeSize);
- }
- }
-
- public void testMessageEncodeSizeWithPacket() throws Exception
- {
- for (int i = 0; i < 10; i++)
- {
- ClientMessage clientMessage = new ClientMessageImpl(0);
-
- clientMessage.putIntProperty(RandomUtil.randomString(),
RandomUtil.randomInt());
- clientMessage.putBooleanProperty(RandomUtil.randomString(),
RandomUtil.randomBoolean());
- clientMessage.putByteProperty(RandomUtil.randomString(),
RandomUtil.randomByte());
- clientMessage.putBytesProperty(RandomUtil.randomString(),
RandomUtil.randomBytes(125));
- clientMessage.putDoubleProperty(RandomUtil.randomString(),
RandomUtil.randomDouble());
- clientMessage.putFloatProperty(RandomUtil.randomString(),
RandomUtil.randomFloat());
- clientMessage.putLongProperty(RandomUtil.randomString(),
RandomUtil.randomLong());
- clientMessage.putShortProperty(RandomUtil.randomString(),
RandomUtil.randomShort());
- clientMessage.putStringProperty(RandomUtil.randomString(),
RandomUtil.randomString());
-
- clientMessage.setDestination(RandomUtil.randomSimpleString());
-
- byte[] bytes = RandomUtil.randomBytes(1000);
-
- HornetQBuffer body = HornetQChannelBuffers.dynamicBuffer(bytes);
-
- clientMessage.setBuffer(body);
-
- int clientEncodeSize = clientMessage.getEncodeSize();
-
- SessionSendMessage packet = new SessionSendMessage(clientMessage, false);
-
- HornetQBuffer buffer =
HornetQChannelBuffers.dynamicBuffer(packet.getRequiredBufferSize());
-
- packet.encode(buffer);
-
- int wireSize = buffer.writerIndex();
-
- assertEquals(wireSize, packet.getRequiredBufferSize());
-
- SessionSendMessage received = new SessionSendMessage();
-
- //The length
- buffer.readInt();
- //The packet type byte
- buffer.readByte();
-
- received.decode(buffer);
-
- ServerMessage serverMessage = received.getServerMessage();
-
- int serverEncodeSize = serverMessage.getEncodeSize();
-
- assertEquals(clientEncodeSize, serverEncodeSize);
- }
- }
-}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/String64KLimitTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/String64KLimitTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/String64KLimitTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -90,16 +90,16 @@
String s4 = genString(10 * 64 * 1024);
ClientMessage tm1 = session.createClientMessage(false);
- tm1.getBuffer().writeString(s1);
+ tm1.getBodyBuffer().writeString(s1);
ClientMessage tm2 = session.createClientMessage(false);
- tm2.getBuffer().writeString(s2);
+ tm2.getBodyBuffer().writeString(s2);
ClientMessage tm3 = session.createClientMessage(false);
- tm3.getBuffer().writeString(s3);
+ tm3.getBodyBuffer().writeString(s3);
ClientMessage tm4 = session.createClientMessage(false);
- tm4.getBuffer().writeString(s4);
+ tm4.getBodyBuffer().writeString(s4);
producer.send(tm1);
@@ -113,23 +113,23 @@
assertNotNull(rm1);
- assertEquals(s1, rm1.getBuffer().readString());
+ assertEquals(s1, rm1.getBodyBuffer().readString());
ClientMessage rm2 = consumer.receive(1000);
assertNotNull(rm2);
- assertEquals(s2, rm2.getBuffer().readString());
+ assertEquals(s2, rm2.getBodyBuffer().readString());
ClientMessage rm3 = consumer.receive(1000);
- assertEquals(s3, rm3.getBuffer().readString());
+ assertEquals(s3, rm3.getBodyBuffer().readString());
assertNotNull(rm3);
ClientMessage rm4 = consumer.receive(1000);
- assertEquals(s4, rm4.getBuffer().readString());
+ assertEquals(s4, rm4.getBodyBuffer().readString());
assertNotNull(rm4);
}
@@ -155,15 +155,15 @@
String s4 = genString(10 * 64 * 1024);
ClientMessage tm1 = session.createClientMessage(false);
- tm1.getBuffer().writeUTF(s1);
+ tm1.getBodyBuffer().writeUTF(s1);
ClientMessage tm2 = session.createClientMessage(false);
- tm2.getBuffer().writeUTF(s2);
+ tm2.getBodyBuffer().writeUTF(s2);
try
{
ClientMessage tm3 = session.createClientMessage(false);
- tm3.getBuffer().writeUTF(s3);
+ tm3.getBodyBuffer().writeUTF(s3);
fail("can not write UTF string bigger than 64K");
}
catch (Exception e)
@@ -173,7 +173,7 @@
try
{
ClientMessage tm4 = session.createClientMessage(false);
- tm4.getBuffer().writeUTF(s4);
+ tm4.getBodyBuffer().writeUTF(s4);
fail("can not write UTF string bigger than 64K");
}
catch (Exception e)
@@ -191,8 +191,8 @@
assertNotNull(rm2);
- assertEquals(s1, rm1.getBuffer().readUTF());
- assertEquals(s2, rm2.getBuffer().readUTF());
+ assertEquals(s1, rm1.getBodyBuffer().readUTF());
+ assertEquals(s2, rm2.getBodyBuffer().readUTF());
}
// Protected -----------------------------------------------------
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AddressSettingsTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AddressSettingsTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AddressSettingsTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -78,9 +78,9 @@
session.createQueue(dlaB, dlqB, false);
ClientSession sendSession = sf.createSession(false, true, true);
ClientMessage cm = sendSession.createClientMessage(true);
- cm.getBuffer().writeString("A");
+ cm.getBodyBuffer().writeString("A");
ClientMessage cm2 = sendSession.createClientMessage(true);
- cm2.getBuffer().writeString("B");
+ cm2.getBodyBuffer().writeString("B");
ClientProducer cp1 = sendSession.createProducer(addressA);
ClientProducer cp2 = sendSession.createProducer(addressB);
cp1.send(cm);
@@ -102,10 +102,10 @@
cc2.close();
message = dlqARec.receive(5000);
assertNotNull(message);
- assertEquals("A", message.getBuffer().readString());
+ assertEquals("A", message.getBodyBuffer().readString());
message = dlqBrec.receive(5000);
assertNotNull(message);
- assertEquals("B", message.getBuffer().readString());
+ assertEquals("B", message.getBodyBuffer().readString());
sendSession.close();
session.close();
}
@@ -141,9 +141,9 @@
session.createQueue(dlaB, dlqB, false);
ClientSession sendSession = sf.createSession(false, true, true);
ClientMessage cm = sendSession.createClientMessage(true);
- cm.getBuffer().writeString("A");
+ cm.getBodyBuffer().writeString("A");
ClientMessage cm2 = sendSession.createClientMessage(true);
- cm2.getBuffer().writeString("B");
+ cm2.getBodyBuffer().writeString("B");
ClientProducer cp1 = sendSession.createProducer(addressA);
ClientProducer cp2 = sendSession.createProducer(addressB);
cp1.send(cm);
@@ -165,10 +165,10 @@
cc2.close();
message = dlqARec.receive(5000);
assertNotNull(message);
- assertEquals("A", message.getBuffer().readString());
+ assertEquals("A", message.getBodyBuffer().readString());
message = dlqBrec.receive(5000);
assertNotNull(message);
- assertEquals("B", message.getBuffer().readString());
+ assertEquals("B", message.getBodyBuffer().readString());
sendSession.close();
session.close();
}
@@ -204,9 +204,9 @@
session.createQueue(dlaB, dlqB, false);
ClientSession sendSession = sf.createSession(false, true, true);
ClientMessage cm = sendSession.createClientMessage(true);
- cm.getBuffer().writeString("A");
+ cm.getBodyBuffer().writeString("A");
ClientMessage cm2 = sendSession.createClientMessage(true);
- cm2.getBuffer().writeString("B");
+ cm2.getBodyBuffer().writeString("B");
ClientProducer cp1 = sendSession.createProducer(addressA);
ClientProducer cp2 = sendSession.createProducer(addressB);
cp1.send(cm);
@@ -228,10 +228,10 @@
cc2.close();
message = dlqARec.receive(5000);
assertNotNull(message);
- assertEquals("A", message.getBuffer().readString());
+ assertEquals("A", message.getBodyBuffer().readString());
message = dlqBrec.receive(5000);
assertNotNull(message);
- assertEquals("B", message.getBuffer().readString());
+ assertEquals("B", message.getBodyBuffer().readString());
sendSession.close();
session.close();
}
@@ -273,11 +273,11 @@
session.createQueue(dlaC, dlqC, false);
ClientSession sendSession = sf.createSession(false, true, true);
ClientMessage cm = sendSession.createClientMessage(true);
- cm.getBuffer().writeString("A");
+ cm.getBodyBuffer().writeString("A");
ClientMessage cm2 = sendSession.createClientMessage(true);
- cm2.getBuffer().writeString("B");
+ cm2.getBodyBuffer().writeString("B");
ClientMessage cm3 = sendSession.createClientMessage(true);
- cm3.getBuffer().writeString("C");
+ cm3.getBodyBuffer().writeString("C");
ClientProducer cp1 = sendSession.createProducer(addressA2);
ClientProducer cp2 = sendSession.createProducer(addressB2);
ClientProducer cp3 = sendSession.createProducer(addressC);
@@ -307,13 +307,13 @@
cc3.close();
message = dlqARec.receive(5000);
assertNotNull(message);
- assertEquals("A", message.getBuffer().readString());
+ assertEquals("A", message.getBodyBuffer().readString());
message = dlqBrec.receive(5000);
assertNotNull(message);
- assertEquals("B", message.getBuffer().readString());
+ assertEquals("B", message.getBodyBuffer().readString());
message = dlqCrec.receive(5000);
assertNotNull(message);
- assertEquals("C", message.getBuffer().readString());
+ assertEquals("C", message.getBodyBuffer().readString());
sendSession.close();
session.close();
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerRoundRobinTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerRoundRobinTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerRoundRobinTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -57,7 +57,7 @@
for (int i = 0; i < numMessage; i++)
{
ClientMessage cm = session.createClientMessage(false);
- cm.getBuffer().writeInt(i);
+ cm.getBodyBuffer().writeInt(i);
cp.send(cm);
}
int currMessage = 0;
@@ -67,7 +67,7 @@
{
ClientMessage cm = consumers[j].receive(5000);
assertNotNull(cm);
- assertEquals(currMessage++, cm.getBuffer().readInt());
+ assertEquals(currMessage++, cm.getBodyBuffer().readInt());
}
}
//sendSession.close();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -88,7 +88,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
// assert that all the messages are there and none have been acked
assertEquals(0,
((Queue)server.getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
@@ -122,7 +122,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
// assert that all the messages are there and none have been acked
assertEquals(0,
((Queue)server.getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
@@ -156,7 +156,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
if (i < 50)
{
message2.acknowledge();
@@ -194,7 +194,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
if (i < 50)
{
message2.acknowledge();
@@ -347,7 +347,7 @@
{
ClientMessage message = session.createClientMessage(false);
- message.getBuffer().writeBytes(bytes);
+ message.getBodyBuffer().writeBytes(bytes);
message.putIntProperty("count", i);
@@ -407,7 +407,7 @@
{
ClientMessage message = session.createClientMessage(false);
- message.getBuffer().writeBytes(bytes);
+ message.getBodyBuffer().writeBytes(bytes);
message.putIntProperty("count", i);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -264,7 +264,7 @@
ClientMessage msg = createTextMessage(session, "This one will
expire");
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
msg.setExpiration(System.currentTimeMillis() + 100);
@@ -291,7 +291,7 @@
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
@@ -395,7 +395,7 @@
ClientMessage msg = createTextMessage(session1, "Msg" + i);
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
}
@@ -421,7 +421,7 @@
assertNotNull("expected message at i = " + i, msg);
- assertEquals("Msg" + i, msg.getBuffer().readString());
+ assertEquals("Msg" + i, msg.getBodyBuffer().readString());
msg.acknowledge();
@@ -456,7 +456,7 @@
ClientMessage msg = createTextMessage(session1, "Msg" + i);
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
}
@@ -470,7 +470,7 @@
ClientMessage msg = cons2.receive(1000);
assertNotNull("expected message at i = " + i, msg);
- assertEquals("Msg" + i, msg.getBuffer().readString());
+ assertEquals("Msg" + i, msg.getBodyBuffer().readString());
msg.acknowledge();
@@ -484,7 +484,7 @@
assertNotNull("expected message at i = " + i, msg);
- assertEquals("Msg" + i, msg.getBuffer().readString());
+ assertEquals("Msg" + i, msg.getBodyBuffer().readString());
msg.acknowledge();
@@ -607,7 +607,7 @@
if (largeMessages)
{
- message.getBuffer().readBytes(new byte[600]);
+ message.getBodyBuffer().readBytes(new byte[600]);
}
latchRead.countDown();
@@ -632,7 +632,7 @@
ClientMessage msg = createTextMessage(session, "Msg" + i);
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
}
@@ -790,7 +790,7 @@
ClientMessage msg = createTextMessage(session, "Msg" + i);
if (largeMessage)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
}
@@ -934,7 +934,7 @@
ClientMessage msg = createTextMessage(sessionA, "Msg" + i);
if (largeMessages)
{
- msg.getBuffer().writeBytes(new byte[600]);
+ msg.getBodyBuffer().writeBytes(new byte[600]);
}
prod.send(msg);
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -97,7 +97,7 @@
message.setDestination(QUEUE);
- message.getBuffer().writeString("testINVMCoreClient");
+ message.getBodyBuffer().writeString("testINVMCoreClient");
producer.send(message);
}
@@ -112,7 +112,7 @@
{
ClientMessage message2 = consumer.receive();
- HornetQBuffer buffer = message2.getBuffer();
+ HornetQBuffer buffer = message2.getBodyBuffer();
assertEquals("testINVMCoreClient", buffer.readString());
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeadLetterAddressTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeadLetterAddressTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeadLetterAddressTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -61,7 +61,7 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
// force a cancel
clientSession.rollback();
m = clientConsumer.receiveImmediate();
@@ -70,7 +70,7 @@
clientConsumer = clientSession.createConsumer(dlq);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
}
public void testBasicSendToMultipleQueues() throws Exception
@@ -93,7 +93,7 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
// force a cancel
clientSession.rollback();
m = clientConsumer.receiveImmediate();
@@ -103,13 +103,13 @@
m = clientConsumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
clientConsumer.close();
clientConsumer = clientSession.createConsumer(dlq2);
m = clientConsumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
clientConsumer.close();
}
@@ -127,7 +127,7 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
// force a cancel
clientSession.rollback();
m = clientConsumer.receiveImmediate();
@@ -174,7 +174,7 @@
{
origIds.put("Message:" + j, tm.getMessageID());
}
- assertEquals("Message:" + j, tm.getBuffer().readString());
+ assertEquals("Message:" + j, tm.getBodyBuffer().readString());
}
clientSession.rollback();
}
@@ -192,7 +192,7 @@
assertNotNull(tm);
- String text = tm.getBuffer().readString();
+ String text = tm.getBodyBuffer().readString();
assertEquals("Message:" + i, text);
// Check the headers
@@ -248,7 +248,7 @@
clientConsumer = clientSession.createConsumer(deadLetterQueue);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
}
public void testDeadlLetterAddressWithWildcardAddressSettings() throws Exception
@@ -288,7 +288,7 @@
clientConsumer = clientSession.createConsumer(deadLetterQueue);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
}
public void testDeadLetterAddressWithOverridenSublevelAddressSettings() throws
Exception
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeliveryOrderTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeliveryOrderTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/DeliveryOrderTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -56,7 +56,7 @@
for (int i = 0; i < numMessages; i++)
{
ClientMessage cm = sendSession.createClientMessage(false);
- cm.getBuffer().writeInt(i);
+ cm.getBodyBuffer().writeInt(i);
cp.send(cm);
if (i % 10 == 0)
{
@@ -70,7 +70,7 @@
{
ClientMessage cm = c.receive(5000);
assertNotNull(cm);
- assertEquals(i, cm.getBuffer().readInt());
+ assertEquals(i, cm.getBodyBuffer().readInt());
}
sendSession.close();
}
@@ -97,7 +97,7 @@
for (int i = 0; i < numMessages; i++)
{
ClientMessage cm = sendSession.createClientMessage(false);
- cm.getBuffer().writeInt(i);
+ cm.getBodyBuffer().writeInt(i);
cp.send(cm);
}
ClientConsumer c = sendSession.createConsumer(queueA);
@@ -107,7 +107,7 @@
ClientMessage cm = c.receive(5000);
assertNotNull(cm);
cm.acknowledge();
- assertEquals(i, cm.getBuffer().readInt());
+ assertEquals(i, cm.getBodyBuffer().readInt());
}
sendSession.rollback();
for (int i = 0; i < numMessages; i++)
@@ -115,7 +115,7 @@
ClientMessage cm = c.receive(5000);
assertNotNull(cm);
cm.acknowledge();
- assertEquals(i, cm.getBuffer().readInt());
+ assertEquals(i, cm.getBodyBuffer().readInt());
}
sendSession.close();
}
@@ -155,7 +155,7 @@
for (int i = 0; i < numMessage; i++)
{
ClientMessage cm = sendSession.createClientMessage(false);
- cm.getBuffer().writeInt(count.getAndIncrement());
+ cm.getBodyBuffer().writeInt(count.getAndIncrement());
clientProducer.send(cm);
}
assertTrue(latch.await(10, TimeUnit.SECONDS));
@@ -194,7 +194,7 @@
public void onMessage(ClientMessage message)
{
- int i = message.getBuffer().readInt();
+ int i = message.getBodyBuffer().readInt();
try
{
message.acknowledge();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ExpiryAddressTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ExpiryAddressTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ExpiryAddressTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -69,7 +69,7 @@
clientConsumer = clientSession.createConsumer(eq);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
m.acknowledge();
// PageSize should be the same as when it started
@@ -117,7 +117,7 @@
log.info("acking");
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
clientConsumer.close();
@@ -130,7 +130,7 @@
log.info("acking");
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
clientConsumer.close();
@@ -197,7 +197,7 @@
assertNotNull(tm);
- String text = tm.getBuffer().readString();
+ String text = tm.getBodyBuffer().readString();
assertEquals("Message:" + i, text);
// Check the headers
@@ -234,7 +234,7 @@
clientConsumer = clientSession.createConsumer(eq);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
m.acknowledge();
}
@@ -264,7 +264,7 @@
clientConsumer = clientSession.createConsumer(eq);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
m.acknowledge();
}
@@ -307,7 +307,7 @@
clientConsumer = clientSession.createConsumer(specificExpiryQueue);
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
m.acknowledge();
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/HeuristicXATest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/HeuristicXATest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/HeuristicXATest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -51,7 +51,9 @@
final SimpleString ADDRESS = new SimpleString("ADDRESS");
-
+
+ final String body = "this is the body";
+
// Attributes ----------------------------------------------------
private MBeanServer mbeanServer;
@@ -120,7 +122,7 @@
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[123]);
+ msg.getBodyBuffer().writeString(body);
producer.send(msg);
@@ -173,7 +175,7 @@
msg = consumer.receive(1000);
assertNotNull(msg);
msg.acknowledge();
- assertEquals(123, msg.getBodySize());
+ assertEquals(body, msg.getBodyBuffer().readString());
session.commit();
session.close();
@@ -227,7 +229,7 @@
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[123]);
+ msg.getBodyBuffer().writeString(body);
producer.send(msg);
@@ -267,8 +269,8 @@
msg = consumer.receive(1000);
assertNotNull(msg);
msg.acknowledge();
- assertEquals(123, msg.getBodySize());
-
+ assertEquals(body, msg.getBodyBuffer().readString());
+
session.commit();
session.close();
}
@@ -334,7 +336,7 @@
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[123]);
+ msg.getBodyBuffer().writeString(body);
producer.send(msg);
@@ -374,7 +376,7 @@
msg = consumer.receive(1000);
assertNotNull(msg);
msg.acknowledge();
- assertEquals(123, msg.getBodySize());
+ assertEquals(body, msg.getBodyBuffer().readString());
session.commit();
session.close();
@@ -449,7 +451,7 @@
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[123]);
+ msg.getBodyBuffer().writeBytes(new byte[123]);
producer.send(msg);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/JournalCrashTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/JournalCrashTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/JournalCrashTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -178,7 +178,7 @@
{
ClientMessage msg = session.createClientMessage(true);
msg.getProperties().putIntProperty(new SimpleString("key"), i);
- msg.getBuffer().writeUTF("message " + i);
+ msg.getBodyBuffer().writeUTF("message " + i);
prod.send(msg);
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -31,7 +31,7 @@
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.Message;
-import org.hornetq.core.persistence.impl.journal.FileLargeServerMessage;
+import org.hornetq.core.persistence.impl.journal.LargeServerMessageImpl;
import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HornetQServer;
@@ -53,7 +53,6 @@
*/
public class LargeMessageTest extends LargeMessageTestBase
{
-
// Constants -----------------------------------------------------
final static int RECEIVE_WAIT_TIME = 60000;
@@ -114,7 +113,7 @@
try
{
- msg1.getBuffer().readByte();
+ msg1.getBodyBuffer().readByte();
fail("Exception was expected");
}
catch (Throwable ignored)
@@ -200,7 +199,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
session.close();
@@ -224,7 +223,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
msg1.acknowledge();
@@ -241,7 +240,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
msg1.acknowledge();
@@ -305,9 +304,12 @@
assertNotNull(msg);
msg.acknowledge();
assertEquals(1, msg.getDeliveryCount());
+
+ log.info("body buffer is " + msg.getBodyBuffer());
+
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg.getBodyBuffer().readByte());
}
session.rollback();
@@ -322,7 +324,7 @@
msg.acknowledge();
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg.getBodyBuffer().readByte());
}
assertEquals(2, msg.getDeliveryCount());
msg.acknowledge();
@@ -410,7 +412,7 @@
for (int j = 0; j < messageSize; j++)
{
- assertEquals(getSamplebyte(j), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(j), msg1.getBodyBuffer().readByte());
}
consumerExpiry.close();
@@ -428,7 +430,7 @@
for (int j = 0; j < messageSize; j++)
{
- assertEquals(getSamplebyte(j), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(j), msg1.getBodyBuffer().readByte());
}
consumerExpiry.close();
@@ -450,7 +452,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
session.commit();
@@ -545,7 +547,7 @@
for (int j = 0; j < messageSize; j++)
{
- assertEquals(getSamplebyte(j), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(j), msg1.getBodyBuffer().readByte());
}
consumerExpiry.close();
@@ -562,7 +564,7 @@
for (int j = 0; j < messageSize; j++)
{
- assertEquals(getSamplebyte(j), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(j), msg1.getBodyBuffer().readByte());
}
consumerExpiry.close();
@@ -589,7 +591,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
session.commit();
@@ -674,7 +676,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
session.close();
@@ -698,7 +700,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg1.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg1.getBodyBuffer().readByte());
}
msg1.acknowledge();
@@ -802,7 +804,7 @@
for (int i = 0; i < messageSize; i++)
{
- assertEquals(getSamplebyte(i), msg2.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg2.getBodyBuffer().readByte());
}
session.close();
@@ -1668,7 +1670,7 @@
assertNotNull(clientMessage);
- assertEquals(numberOfBytes, clientMessage.getBuffer().writerIndex());
+ assertEquals(numberOfBytes, clientMessage.getBodyBuffer().writerIndex());
clientMessage.acknowledge();
@@ -1748,7 +1750,7 @@
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
- Message clientFile = session.createClientMessage(true);
+ ClientMessage clientFile = session.createClientMessage(true);
clientFile.setBodyInputStream(createFakeLargeStream(SIZE));
producer.send(clientFile);
@@ -1782,7 +1784,7 @@
{
for (int byteRead = 0; byteRead < SIZE; byteRead++)
{
- assertEquals(getSamplebyte(byteRead), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(byteRead),
msg.getBodyBuffer().readByte());
}
}
@@ -1850,7 +1852,7 @@
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
- Message clientFile = session.createClientMessage(true);
+ ClientMessage clientFile = session.createClientMessage(true);
clientFile.setBodyInputStream(createFakeLargeStream(SIZE));
producer.send(clientFile);
@@ -1883,7 +1885,7 @@
{
for (int byteRead = 0; byteRead < SIZE; byteRead++)
{
- assertEquals(getSamplebyte(byteRead), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(byteRead),
msg.getBodyBuffer().readByte());
}
}
@@ -1947,7 +1949,7 @@
session.createQueue(ADDRESS, ADDRESS, null, true);
- Message clientFile = session.createClientMessage(true);
+ ClientMessage clientFile = session.createClientMessage(true);
clientFile.setBodyInputStream(createFakeLargeStream(SIZE));
ClientProducer producer = session.createProducer(ADDRESS);
@@ -2024,7 +2026,7 @@
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
- Message msg = session.createClientMessage(true);
+ ClientMessage msg = session.createClientMessage(true);
msg.setBodyInputStream(createFakeLargeStream(SIZE));
msg.putIntProperty(new SimpleString("key"), i);
producer.send(msg);
@@ -2086,55 +2088,55 @@
public void testSendServerMessage() throws Exception
{
HornetQServer server = createServer(true);
-
+
server.start();
-
+
ClientSessionFactory sf = createFactory(false);
-
+
ClientSession session = sf.createSession(false, false);
-
+
try
{
- FileLargeServerMessage fileMessage = new
FileLargeServerMessage((JournalStorageManager)server.getStorageManager());
-
+ LargeServerMessageImpl fileMessage = new
LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());
+
fileMessage.setMessageID(1005);
-
- for (int i = 0 ; i < LARGE_MESSAGE_SIZE; i++)
+
+ for (int i = 0; i < LARGE_MESSAGE_SIZE; i++)
{
- fileMessage.addBytes(new byte[]{getSamplebyte(i)});
+ fileMessage.addBytes(new byte[] { getSamplebyte(i) });
}
-
+
fileMessage.releaseResources();
-
+
session.createQueue(ADDRESS, ADDRESS, true);
-
+
ClientProducer prod = session.createProducer(ADDRESS);
-
+
prod.send(fileMessage);
-
+
fileMessage.deleteFile();
-
+
session.commit();
-
+
session.start();
-
+
ClientConsumer cons = session.createConsumer(ADDRESS);
-
+
ClientMessage msg = cons.receive(5000);
-
+
assertNotNull(msg);
-
+
assertEquals(msg.getBodySize(), LARGE_MESSAGE_SIZE);
-
- for (int i = 0 ; i < LARGE_MESSAGE_SIZE; i++)
+
+ for (int i = 0; i < LARGE_MESSAGE_SIZE; i++)
{
- assertEquals(getSamplebyte(i), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg.getBodyBuffer().readByte());
}
-
+
msg.acknowledge();
-
+
session.commit();
-
+
}
finally
{
@@ -2143,8 +2145,6 @@
}
}
-
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@@ -2262,12 +2262,12 @@
try
{
- assertEqualsByteArrays(body.writerIndex(), body.array(),
message2.getBuffer().array());
+ assertEqualsByteArrays(body.writerIndex(), body.array(),
message2.getBodyBuffer().array());
}
catch (AssertionFailedError e)
{
log.info("Expected buffer:" + dumbBytesHex(body.array(), 40));
- log.info("Arriving buffer:" +
dumbBytesHex(message2.getBuffer().array(), 40));
+ log.info("Arriving buffer:" +
dumbBytesHex(message2.getBodyBuffer().array(), 40));
throw e;
}
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageCounterTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageCounterTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageCounterTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -91,7 +91,7 @@
session.commit();
- assertEquals("m" + i, message.getBuffer().readString());
+ assertEquals("m" + i, message.getBodyBuffer().readString());
}
session.close();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageGroupingTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageGroupingTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessageGroupingTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -108,14 +108,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(50, dummyMessageHandler2.list.size());
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer.close();
@@ -155,14 +155,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(50, dummyMessageHandler2.list.size());
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer.close();
@@ -196,11 +196,11 @@
{
ClientMessage cm = consumer.receive(500);
assertNotNull(cm);
- assertEquals(cm.getBuffer().readString(), "m" + i);
+ assertEquals(cm.getBodyBuffer().readString(), "m" + i);
i++;
cm = consumer2.receive(500);
assertNotNull(cm);
- assertEquals(cm.getBuffer().readString(), "m" + i);
+ assertEquals(cm.getBodyBuffer().readString(), "m" + i);
}
log.info("closing consumers");
@@ -218,13 +218,13 @@
{
ClientMessage cm = consumer.receive(500);
assertNotNull(cm);
- assertEquals(cm.getBuffer().readString(), "m" + i);
+ assertEquals(cm.getBodyBuffer().readString(), "m" + i);
}
for (int i = 1; i < numMessages; i += 2)
{
ClientMessage cm = consumer.receive(500);
assertNotNull(cm);
- assertEquals(cm.getBuffer().readString(), "m" + i);
+ assertEquals(cm.getBodyBuffer().readString(), "m" + i);
}
consumer.close();
}
@@ -258,7 +258,7 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 1;
}
consumer.close();
@@ -300,14 +300,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer.close();
@@ -352,14 +352,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
latch = new CountDownLatch(numMessages);
@@ -371,14 +371,14 @@
i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer = this.clientSession.createConsumer(qName);
@@ -426,14 +426,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer.close();
@@ -482,14 +482,14 @@
int i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
latch = new CountDownLatch(numMessages);
@@ -505,14 +505,14 @@
i = 0;
for (ClientMessage message : dummyMessageHandler.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
assertEquals(dummyMessageHandler2.list.size(), 50);
i = 1;
for (ClientMessage message : dummyMessageHandler2.list)
{
- assertEquals(message.getBuffer().readString(), "m" + i);
+ assertEquals(message.getBodyBuffer().readString(), "m" + i);
i += 2;
}
consumer = this.clientSession.createConsumer(qName);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessagePriorityTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessagePriorityTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/MessagePriorityTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -64,18 +64,12 @@
ClientProducer producer = session.createProducer(address);
- ClientMessage[] messages = new ClientMessage[10];
for (int i = 0; i < 10; i++)
{
ClientMessage m = createTextMessage(Integer.toString(i), session);
- m.setPriority((byte)i);
- messages[i] = m;
+ m.setPriority((byte)i);
+ producer.send(m);
}
- // send message with lower priority first
- for (int i = 0; i < 10; i++)
- {
- producer.send(messages[i]);
- }
ClientConsumer consumer = session.createConsumer(queue);
@@ -86,8 +80,7 @@
{
ClientMessage m = consumer.receive(500);
assertNotNull(m);
- assertEquals(messages[i].getPriority(), m.getPriority());
- assertEquals(m.getBuffer().readString(), messages[i].getBuffer().readString());
+ assertEquals(i, m.getPriority());
}
consumer.close();
@@ -112,26 +105,19 @@
ClientConsumer consumer = session.createConsumer(queue);
- ClientMessage[] messages = new ClientMessage[10];
for (int i = 0; i < 10; i++)
{
ClientMessage m = createTextMessage(Integer.toString(i), session);
m.setPriority((byte)i);
- messages[i] = m;
+ producer.send(m);
}
- // send message with lower priority first
- for (int i = 0; i < 10; i++)
- {
- producer.send(messages[i]);
- }
// expect to consumer message with higher priority first
for (int i = 9; i >= 0; i--)
{
ClientMessage m = consumer.receive(500);
assertNotNull(m);
- assertEquals(messages[i].getPriority(), m.getPriority());
- assertEquals(m.getBuffer().readString(), messages[i].getBuffer().readString());
+ assertEquals(i, m.getPriority());
}
consumer.close();
@@ -252,7 +238,7 @@
ClientMessage m = consumer.receive(500);
assertNotNull(m);
assertEquals(expectedPriority, m.getPriority());
- assertEquals(expectedStringInBody, m.getBuffer().readString());
+ assertEquals(expectedStringInBody, m.getBodyBuffer().readString());
}
// Inner classes -------------------------------------------------
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/NewDeadLetterAddressTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -58,7 +58,7 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "heyho!");
+ assertEquals(m.getBodyBuffer().readString(), "heyho!");
}
@Override
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -13,6 +13,7 @@
package org.hornetq.tests.integration.client;
+import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
@@ -65,7 +66,7 @@
private static final int RECEIVE_TIMEOUT = 30000;
private static final int PAGE_MAX = 100 * 1024;
-
+
private static final int PAGE_SIZE = 10 * 1024;
// Attributes ----------------------------------------------------
@@ -108,24 +109,23 @@
ClientMessage message = null;
- byte[] body = null;
+ byte[] body = new byte[numberOfIntegers * 4];
+
+ ByteBuffer bb = ByteBuffer.wrap(body);
+
+ for (int j = 1; j <= numberOfIntegers; j++)
+ {
+ bb.putInt(j);
+ }
for (int i = 0; i < numberOfMessages; i++)
{
message = session.createClientMessage(true);
- HornetQBuffer bodyLocal = message.getBuffer();
+ HornetQBuffer bodyLocal = message.getBodyBuffer();
- for (int j = 1; j <= numberOfIntegers; j++)
- {
- bodyLocal.writeInt(j);
- }
-
- if (body == null)
- {
- body = bodyLocal.array();
- }
-
+ bodyLocal.writeBytes(body);
+
message.putIntProperty(new SimpleString("id"), i);
producer.send(message);
@@ -170,12 +170,12 @@
try
{
- assertEqualsByteArrays(body.length, body, message2.getBuffer().array());
+ this.assertBodiesEqual(body, message2.getBodyBuffer());
}
catch (AssertionFailedError e)
{
log.info("Expected buffer:" + dumbBytesHex(body, 40));
- log.info("Arriving buffer:" +
dumbBytesHex(message2.getBuffer().array(), 40));
+ log.info("Arriving buffer:" +
dumbBytesHex(message2.getBodyBuffer().array(), 40));
throw e;
}
}
@@ -199,6 +199,15 @@
}
}
+
+ private void assertBodiesEqual(byte[] body, HornetQBuffer buffer)
+ {
+ byte[] other = new byte[body.length];
+
+ buffer.readBytes(other);
+
+ assertEqualsByteArrays(body, other);
+ }
/**
* - Make a destination in page mode
@@ -234,7 +243,8 @@
ClientProducer producer = session.createProducer(ADDRESS);
- HornetQBuffer bodyLocal = HornetQChannelBuffers.buffer(DataConstants.SIZE_INT *
numberOfIntegers);
+ byte[] body = new byte[DataConstants.SIZE_INT * numberOfIntegers];
+ //HornetQBuffer bodyLocal = HornetQChannelBuffers.buffer(DataConstants.SIZE_INT
* numberOfIntegers);
ClientMessage message = null;
@@ -242,7 +252,7 @@
while (true)
{
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
// Stop sending message as soon as we start paging
if
(server.getPostOffice().getPagingManager().getPageStore(ADDRESS).isPaging())
@@ -265,7 +275,7 @@
for (int i = 0; i < 10; i++)
{
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
message.putIntProperty(new SimpleString("id"), i);
// Consume messages to force an eventual out of order delivery
@@ -386,8 +396,8 @@
for (int i = 0; i < numberOfMessages; i++)
{
message = session.createClientMessage(true);
-
- message.setBuffer(HornetQChannelBuffers.wrappedBuffer(body));
+
+ message.getBodyBuffer().writeBytes(body);
message.putIntProperty(new SimpleString("id"), i);
TestSupportPageStore store = (TestSupportPageStore)server.getPostOffice()
@@ -439,13 +449,13 @@
}
try
- {
- assertEqualsByteArrays(body.length, body, message2.getBuffer().array());
+ {
+ this.assertBodiesEqual(body, message2.getBodyBuffer());
}
catch (AssertionFailedError e)
{
log.info("Expected buffer:" + dumbBytesHex(body, 40));
- log.info("Arriving buffer:" +
dumbBytesHex(message2.getBuffer().array(), 40));
+ log.info("Arriving buffer:" +
dumbBytesHex(message2.getBodyBuffer().array(), 40));
throw e;
}
}
@@ -506,7 +516,7 @@
{
message = session.createClientMessage(true);
- HornetQBuffer bodyLocal = message.getBuffer();
+ HornetQBuffer bodyLocal = message.getBodyBuffer();
for (int j = 1; j <= numberOfIntegers; j++)
{
@@ -579,7 +589,7 @@
{
message = session.createClientMessage(true);
- HornetQBuffer bodyLocal = message.getBuffer();
+ HornetQBuffer bodyLocal = message.getBodyBuffer();
for (int j = 1; j <= numberOfIntegers; j++)
{
@@ -669,10 +679,10 @@
for (int i = 0; i < numberOfMessages; i++)
{
- HornetQBuffer bodyLocal = HornetQChannelBuffers.wrappedBuffer(new
byte[1024]);
+ byte[] body = new byte[1024];
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
producer.send(message);
}
@@ -697,10 +707,10 @@
for (int i = 0; i < numberOfMessages; i++)
{
- HornetQBuffer bodyLocal = HornetQChannelBuffers.wrappedBuffer(new
byte[1024]);
+ byte[] body = new byte[1024];
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
producer.send(message);
}
@@ -724,10 +734,10 @@
for (int i = 0; i < numberOfMessages; i++)
{
- HornetQBuffer bodyLocal = HornetQChannelBuffers.wrappedBuffer(new
byte[1024]);
+ byte[] body = new byte[1024];
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
producer.send(message);
}
@@ -800,11 +810,11 @@
ClientProducer producer = session.createProducer(ADDRESS);
ClientMessage message = null;
+
+ byte[] body = new byte[1024];
- HornetQBuffer bodyLocal = HornetQChannelBuffers.wrappedBuffer(new byte[1024]);
-
message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
+ message.getBodyBuffer().writeBytes(body);
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
@@ -918,7 +928,7 @@
for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producerPaged.send(msg);
producerNonPaged.send(msg);
@@ -1030,7 +1040,7 @@
for (int i = 0; i < NUMBER_MESSAGES_BEFORE_PAGING; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producerA.send(msg);
producerB.send(msg);
@@ -1044,7 +1054,7 @@
for (int i = 0; i < NUMBER_MESSAGES_BEFORE_PAGING; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producerA.send(msg);
producerB.send(msg);
@@ -1058,7 +1068,7 @@
for (int i = NUMBER_MESSAGES_BEFORE_PAGING * 2; i < NUMBER_OF_MESSAGES; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producerA.send(msg);
producerB.send(msg);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -21,7 +21,6 @@
import org.hornetq.core.client.ClientSession;
import org.hornetq.core.client.ClientSessionFactory;
import org.hornetq.core.client.MessageHandler;
-import org.hornetq.core.client.impl.ClientMessageImpl;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.paging.impl.TestSupportPageStore;
import org.hornetq.core.server.HornetQServer;
@@ -29,6 +28,7 @@
import org.hornetq.core.settings.HierarchicalRepository;
import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.SimpleString;
@@ -212,6 +212,8 @@
{
session.createQueue(address, new SimpleString(queueName + i), null, false);
}
+
+ final byte[] bytes = RandomUtil.randomBytes(messageSize);
class MyHandler implements MessageHandler
{
@@ -225,16 +227,12 @@
{
try
{
- // log.info("got message " + count);
+ byte[] bytesRead = new byte[messageSize];
- int availBytes = message.getBuffer().readableBytes();
+ message.getBodyBuffer().readBytes(bytesRead);
+
+ assertEqualsByteArrays(bytes, bytesRead);
- assertEquals(messageSize, availBytes);
-
- byte[] bytes = new byte[availBytes];
-
- message.getBuffer().readBytes(bytes);
-
message.acknowledge();
if (++count == numMessages * numProducers)
@@ -250,8 +248,10 @@
catch (Exception e)
{
log.error("Failed to handle message", e);
-
+
this.exception = e;
+
+ latch.countDown();
}
}
}
@@ -285,11 +285,13 @@
long start = System.currentTimeMillis();
- byte[] bytes = new byte[messageSize];
+
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
for (int j = 0; j < numProducers; j++)
{
@@ -386,7 +388,9 @@
byte[] bytes = new byte[0];
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer.send(message);
@@ -416,7 +420,9 @@
t.start();
- ClientMessage message2 = new ClientMessageImpl(false, bytes);
+ ClientMessage message2 = session.createClientMessage(false);
+
+ message2.getBodyBuffer().writeBytes(bytes);
producer2.send(message2);
@@ -467,7 +473,9 @@
byte[] bytes = new byte[0];
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer.send(message);
@@ -495,7 +503,9 @@
assertEquals(1, waiting);
- message = new ClientMessageImpl(false, bytes);
+ message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer2.send(message);
@@ -541,7 +551,9 @@
byte[] bytes = new byte[0];
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer.send(message);
@@ -587,7 +599,9 @@
session.close();
- message = new ClientMessageImpl(false, bytes);
+ message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer3.send(message);
@@ -633,7 +647,9 @@
byte[] bytes = new byte[2000];
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
final AtomicBoolean closed = new AtomicBoolean(false);
@@ -704,7 +720,9 @@
for (int i = 0; i < numMessages; i++)
{
- ClientMessage message = new ClientMessageImpl(false, bytes);
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(bytes);
producer.send(message);
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ProducerTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -80,7 +80,7 @@
ClientProducer producer = session.createProducer(QUEUE);
ClientMessage message = session.createClientMessage(true);
byte[] body = new byte[1000];
- message.getBuffer().writeBytes(body);
+ message.getBodyBuffer().writeBytes(body);
producer.send(message);
assertTrue(latch.await(5, TimeUnit.SECONDS));
session.close();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/QueueBrowserTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/QueueBrowserTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/QueueBrowserTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -85,7 +85,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
consumer.close();
@@ -96,7 +96,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
consumer.close();
@@ -133,7 +133,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
consumer.close();
@@ -144,7 +144,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
consumer.close();
@@ -184,7 +184,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
session.close();
@@ -219,11 +219,11 @@
for (int i = 0; i < numMessages; i++)
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
message2 = consumer2.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
message2 = consumer3.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
session.close();
@@ -258,17 +258,17 @@
for (int i = 0; i < 50; i++)
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
for (int i = 50; i < numMessages; i++)
{
ClientMessage message2 = consumer2.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
for (int i = 0; i < numMessages; i++)
{
ClientMessage message2 = consumer3.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
session.close();
@@ -312,7 +312,7 @@
{
ClientMessage message2 = consumer.receive(1000);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
// assert that all the messages are there and none have been acked
assertEquals(0,
((Queue)server.getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
@@ -349,7 +349,7 @@
message2.acknowledge();
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
}
// assert that all the messages are there and none have been acked
assertEquals(0,
((Queue)server.getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ReceiveImmediateTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ReceiveImmediateTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/ReceiveImmediateTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -167,7 +167,7 @@
{
ClientMessage message2 = consumer.receiveImmediate();
assertNotNull("did not receive message " + i, message2);
- assertEquals("m" + i, message2.getBuffer().readString());
+ assertEquals("m" + i, message2.getBodyBuffer().readString());
if (!browser)
{
message2.acknowledge();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -18,8 +18,10 @@
import org.hornetq.core.client.ClientProducer;
import org.hornetq.core.client.ClientSession;
import org.hornetq.core.client.ClientSessionFactory;
+import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.utils.SimpleString;
@@ -37,6 +39,9 @@
// Constants -----------------------------------------------------
+ private static final Logger log = Logger.getLogger(SelfExpandingBufferTest.class);
+
+
// Attributes ----------------------------------------------------
HornetQServer service;
@@ -49,20 +54,29 @@
// Public --------------------------------------------------------
- public void testSelfExpandingBufferNetty() throws Exception
+ public void testSelfExpandingBufferNettyPersistent() throws Exception
{
- testSelfExpandingBuffer(true);
+ testSelfExpandingBuffer(true, true);
}
- public void testSelfExpandingBufferInVM() throws Exception
+ public void testSelfExpandingBufferInVMPersistent() throws Exception
{
- testSelfExpandingBuffer(false);
+ testSelfExpandingBuffer(false, true);
}
+
+ public void testSelfExpandingBufferNettyNonPersistent() throws Exception
+ {
+ testSelfExpandingBuffer(true, false);
+ }
- public void testSelfExpandingBuffer(boolean netty) throws Exception
+ public void testSelfExpandingBufferInVMNonPersistent() throws Exception
{
+ testSelfExpandingBuffer(false, false);
+ }
- setUpService(netty);
+ private void testSelfExpandingBuffer(boolean netty, boolean persistent) throws
Exception
+ {
+ setUpService(netty, persistent);
ClientSessionFactory factory;
@@ -83,29 +97,50 @@
session.createQueue(ADDRESS, ADDRESS, true);
ClientMessage msg = session.createClientMessage(true);
+
+ HornetQBuffer buffer = msg.getBodyBuffer();
+
+ log.info("buffer is " + buffer);
+
+ byte[] bytes = RandomUtil.randomBytes(10 * buffer.capacity());
- HornetQBuffer buffer = msg.getBuffer();
-
- for (int i = 0; i < 10; i++)
- {
- buffer.writeBytes(new byte[1024]);
- }
+ buffer.writeBytes(bytes);
ClientProducer prod = session.createProducer(ADDRESS);
prod.send(msg);
+ //Send same message again
+
+ prod.send(msg);
+
ClientConsumer cons = session.createConsumer(ADDRESS);
session.start();
ClientMessage msg2 = cons.receive(3000);
+
assertNotNull(msg2);
+
+ byte[] receivedBytes = new byte[bytes.length];
+// log.info("buffer start pos should be at " +
PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT);
+//
+// log.info("buffer pos at " + msg2.getBodyBuffer().readerIndex());
+//
+// log.info("buffer length should be " +
msg2.getBodyBuffer().readInt(PacketImpl.PACKET_HEADERS_SIZE));
- assertEquals(1024 * 10, msg2.getBodySize());
+ msg2.getBodyBuffer().readBytes(receivedBytes);
+ assertEqualsByteArrays(bytes, receivedBytes);
+ msg2 = cons.receive(3000);
+
+ assertNotNull(msg2);
+
+ msg2.getBodyBuffer().readBytes(receivedBytes);
+
+ assertEqualsByteArrays(bytes, receivedBytes);
}
finally
{
@@ -117,9 +152,9 @@
// Protected -----------------------------------------------------
- protected void setUpService(boolean netty) throws Exception
+ protected void setUpService(boolean netty, boolean persistent) throws Exception
{
- service = createServer(false, createDefaultConfig(netty));
+ service = createServer(persistent, createDefaultConfig(netty));
service.start();
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SessionCreateProducerTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SessionCreateProducerTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SessionCreateProducerTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -34,12 +34,12 @@
cf.setProducerMaxRate(99);
cf.setBlockOnNonPersistentSend(true);
cf.setBlockOnNonPersistentSend(true);
- ClientSessionInternal clientSession = (ClientSessionInternal)
cf.createSession(false, true, true);
+ ClientSessionInternal clientSession =
(ClientSessionInternal)cf.createSession(false, true, true);
ClientProducer producer = clientSession.createProducer();
assertNull(producer.getAddress());
assertEquals(cf.getProducerMaxRate(), producer.getMaxRate());
-
assertEquals(cf.isBlockOnNonPersistentSend(),producer.isBlockOnNonPersistentSend());
- assertEquals(cf.isBlockOnPersistentSend(),producer.isBlockOnPersistentSend());
+ assertEquals(cf.isBlockOnNonPersistentSend(),
producer.isBlockOnNonPersistentSend());
+ assertEquals(cf.isBlockOnPersistentSend(), producer.isBlockOnPersistentSend());
assertFalse(producer.isClosed());
clientSession.close();
}
@@ -59,12 +59,12 @@
cf.setProducerMaxRate(99);
cf.setBlockOnNonPersistentSend(true);
cf.setBlockOnNonPersistentSend(true);
- ClientSessionInternal clientSession = (ClientSessionInternal)
cf.createSession(false, true, true);
+ ClientSessionInternal clientSession =
(ClientSessionInternal)cf.createSession(false, true, true);
ClientProducer producer =
clientSession.createProducer("testAddress");
assertNotNull(producer.getAddress());
assertEquals(cf.getProducerMaxRate(), producer.getMaxRate());
-
assertEquals(cf.isBlockOnNonPersistentSend(),producer.isBlockOnNonPersistentSend());
- assertEquals(cf.isBlockOnPersistentSend(),producer.isBlockOnPersistentSend());
+ assertEquals(cf.isBlockOnNonPersistentSend(),
producer.isBlockOnNonPersistentSend());
+ assertEquals(cf.isBlockOnPersistentSend(), producer.isBlockOnPersistentSend());
assertFalse(producer.isClosed());
clientSession.close();
}
@@ -84,13 +84,13 @@
cf.setProducerMaxRate(99);
cf.setBlockOnNonPersistentSend(true);
cf.setBlockOnNonPersistentSend(true);
- ClientSessionInternal clientSession = (ClientSessionInternal)
cf.createSession(false, true, true);
+ ClientSessionInternal clientSession =
(ClientSessionInternal)cf.createSession(false, true, true);
int rate = 9876;
ClientProducer producer = clientSession.createProducer("testAddress",
rate);
assertNotNull(producer.getAddress());
assertEquals(rate, producer.getMaxRate());
-
assertEquals(cf.isBlockOnNonPersistentSend(),producer.isBlockOnNonPersistentSend());
- assertEquals(cf.isBlockOnPersistentSend(),producer.isBlockOnPersistentSend());
+ assertEquals(cf.isBlockOnNonPersistentSend(),
producer.isBlockOnNonPersistentSend());
+ assertEquals(cf.isBlockOnPersistentSend(), producer.isBlockOnPersistentSend());
assertFalse(producer.isClosed());
clientSession.close();
}
@@ -100,7 +100,7 @@
}
}
- public void testCreateProducer3() throws Exception
+ public void testProducerOnClosedSession() throws Exception
{
HornetQServer service = createServer(false);
try
@@ -110,17 +110,17 @@
cf.setProducerMaxRate(99);
cf.setBlockOnNonPersistentSend(true);
cf.setBlockOnNonPersistentSend(true);
- ClientSessionInternal clientSession = (ClientSessionInternal)
cf.createSession(false, true, true);
- int rate = 9876;
- boolean blockOnSend = false;
- boolean blockOnNonSend = false;
- ClientProducer producer = clientSession.createProducer("testAddress",
9876, blockOnSend, blockOnNonSend);
- assertNotNull(producer.getAddress());
- assertEquals(rate, producer.getMaxRate());
- assertEquals(blockOnSend, producer.isBlockOnNonPersistentSend());
- assertEquals(blockOnNonSend, producer.isBlockOnPersistentSend());
- assertFalse(producer.isClosed());
+ ClientSessionInternal clientSession =
(ClientSessionInternal)cf.createSession(false, true, true);
clientSession.close();
+ try
+ {
+ clientSession.createProducer();
+ fail("should throw exception");
+ }
+ catch (HornetQException e)
+ {
+ assertEquals(e.getCode(), HornetQException.OBJECT_CLOSED);
+ }
}
finally
{
@@ -128,32 +128,4 @@
}
}
- public void testProducerOnClosedSession() throws Exception
- {
- HornetQServer service = createServer(false);
- try
- {
- service.start();
- ClientSessionFactory cf = createInVMFactory();
- cf.setProducerMaxRate(99);
- cf.setBlockOnNonPersistentSend(true);
- cf.setBlockOnNonPersistentSend(true);
- ClientSessionInternal clientSession = (ClientSessionInternal)
cf.createSession(false, true, true);
- clientSession.close();
- try
- {
- clientSession.createProducer();
- fail("should throw exception");
- }
- catch (HornetQException e)
- {
- assertEquals(e.getCode(), HornetQException.OBJECT_CLOSED);
- }
- }
- finally
- {
- service.stop();
- }
- }
-
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/WildCardRoutingTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/WildCardRoutingTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -54,11 +54,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -79,11 +79,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -112,11 +112,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -153,11 +153,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -182,11 +182,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -214,11 +214,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
clientConsumer.close();
clientSession.deleteQueue(queueName);
@@ -272,39 +272,39 @@
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m3", m.getBuffer().readString());
+ assertEquals("m3", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m4", m.getBuffer().readString());
+ assertEquals("m4", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m5", m.getBuffer().readString());
+ assertEquals("m5", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m6", m.getBuffer().readString());
+ assertEquals("m6", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m7", m.getBuffer().readString());
+ assertEquals("m7", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m8", m.getBuffer().readString());
+ assertEquals("m8", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m9", m.getBuffer().readString());
+ assertEquals("m9", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -369,39 +369,39 @@
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m3", m.getBuffer().readString());
+ assertEquals("m3", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m4", m.getBuffer().readString());
+ assertEquals("m4", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m5", m.getBuffer().readString());
+ assertEquals("m5", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m6", m.getBuffer().readString());
+ assertEquals("m6", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m7", m.getBuffer().readString());
+ assertEquals("m7", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m8", m.getBuffer().readString());
+ assertEquals("m8", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m9", m.getBuffer().readString());
+ assertEquals("m9", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -439,11 +439,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -468,11 +468,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -498,11 +498,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -527,11 +527,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -556,7 +556,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -581,11 +581,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
}
@@ -608,7 +608,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -633,7 +633,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -658,7 +658,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -683,7 +683,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -708,7 +708,7 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
@@ -736,11 +736,11 @@
producer2.send(createTextMessage("m2", clientSession));
ClientMessage m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m1", m.getBuffer().readString());
+ assertEquals("m1", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receive(500);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = clientConsumer.receiveImmediate();
assertNull(m);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientCrashTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -78,7 +78,7 @@
// send the message to the queue
Message messageFromClient = consumer.receive(5000);
assertNotNull("no message received", messageFromClient);
- assertEquals(MESSAGE_TEXT_FROM_CLIENT,
messageFromClient.getBuffer().readString());
+ assertEquals(MESSAGE_TEXT_FROM_CLIENT,
messageFromClient.getBodyBuffer().readString());
assertActiveConnections(1 + 1); // One local and one from the other vm
assertActiveSession(1 + 1);
@@ -88,7 +88,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_SERVER);
+ message.getBodyBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_SERVER);
producer.send(message);
log.debug("waiting for the client VM to crash ...");
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientExitTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientExitTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/ClientExitTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -70,7 +70,7 @@
Message message = consumer.receive(15000);
assertNotNull(message);
- assertEquals(MESSAGE_TEXT, message.getBuffer().readString());
+ assertEquals(MESSAGE_TEXT, message.getBodyBuffer().readString());
// the client VM should exit by itself. If it doesn't, that means we have a
problem
// and the test will timeout
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -63,7 +63,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT);
+ message.getBodyBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT);
producer.send(message);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/GracefulClient.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/GracefulClient.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/GracefulClient.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -61,7 +61,7 @@
ClientMessage message = session.createClientMessage(HornetQTextMessage.TYPE,
false, 0,
System.currentTimeMillis(), (byte) 1);
- message.getBuffer().writeString(messageText);
+ message.getBodyBuffer().writeString(messageText);
producer.send(message);
session.start();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -184,7 +184,7 @@
message.putIntProperty(propKey, i);
- message.getBuffer().writeBytes(bytes);
+ message.getBodyBuffer().writeBytes(bytes);
producer0.send(message);
}
@@ -261,7 +261,7 @@
for (int j = 0; j < 1024; j++)
{
- message.getBuffer().readBytes(byteRead);
+ message.getBodyBuffer().readBytes(byteRead);
}
}
@@ -540,7 +540,7 @@
message.putStringProperty(propKey, new SimpleString("bing"));
- message.getBuffer().writeString("doo be doo be doo be doo");
+ message.getBodyBuffer().writeString("doo be doo be doo be doo");
producer0.send(message);
}
@@ -555,7 +555,7 @@
assertEquals(new SimpleString("bong"), val);
- String sval = message.getBuffer().readString();
+ String sval = message.getBodyBuffer().readString();
assertEquals("dee be dee be dee be dee", sval);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -46,7 +46,7 @@
message.putStringProperty(new SimpleString("wibble"), new
SimpleString("bong"));
//Change the body
- HornetQBuffer buffer = message.getBuffer();
+ HornetQBuffer buffer = message.getBodyBuffer();
buffer.readerIndex(0);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -218,7 +218,7 @@
{
ClientMessage message = session.createClientMessage(true);
- message.getBuffer().writeString("message" + i);
+ message.getBodyBuffer().writeString("message" + i);
message.putIntProperty("counter", i);
@@ -313,7 +313,7 @@
{
ClientMessage message = session.createClientMessage(true);
- message.getBuffer().writeString("message" + i);
+ message.getBodyBuffer().writeString("message" + i);
message.putIntProperty("counter", i);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -1706,7 +1706,7 @@
{
ClientMessage message = session.createClientMessage(true);
- message.getBuffer().writeString("message");
+ message.getBodyBuffer().writeString("message");
try
{
@@ -2082,7 +2082,7 @@
*/
protected void assertMessageBody(int i, ClientMessage message)
{
- assertEquals("message" + i, message.getBuffer().readString());
+ assertEquals("message" + i, message.getBodyBuffer().readString());
}
/**
@@ -2092,7 +2092,7 @@
*/
protected void setBody(int i, ClientMessage message) throws Exception
{
- message.getBuffer().writeString("message" + i);
+ message.getBodyBuffer().writeString("message" + i);
}
// Private -------------------------------------------------------
@@ -2115,7 +2115,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -2127,7 +2127,7 @@
{
ClientMessage message2 = consumer.receive();
- assertEquals("aardvarks", message2.getBuffer().readString());
+ assertEquals("aardvarks", message2.getBodyBuffer().readString());
assertEquals(i, message2.getObjectProperty(new
SimpleString("count")));
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -95,7 +95,7 @@
*/
protected void assertMessageBody(int i, ClientMessage message)
{
- HornetQBuffer buffer = message.getBuffer();
+ HornetQBuffer buffer = message.getBodyBuffer();
for (int j = 0; j < ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE * 3;
j++)
{
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/MultiThreadRandomReattachTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -55,7 +55,7 @@
@Override
protected boolean checkSize(final ClientMessage message)
{
- return 0 == message.getBuffer().writerIndex();
+ return 0 == message.getBodyBuffer().writerIndex();
}
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/reattach/ReattachTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -101,7 +101,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -119,7 +119,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getObjectProperty(new
SimpleString("count")));
@@ -175,7 +175,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -213,7 +213,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getIntProperty("count").intValue());
@@ -285,7 +285,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -328,7 +328,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getIntProperty("count").intValue());
@@ -379,7 +379,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -462,7 +462,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -483,7 +483,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getIntProperty("count").intValue());
@@ -530,7 +530,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -569,7 +569,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getIntProperty("count").intValue());
@@ -622,7 +622,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -645,7 +645,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getObjectProperty(new
SimpleString("count")));
@@ -701,7 +701,7 @@
System.currentTimeMillis(),
(byte)1);
message.putIntProperty(new SimpleString("count"), i);
- message.getBuffer().writeString("aardvarks");
+ message.getBodyBuffer().writeString("aardvarks");
producer.send(message);
}
@@ -724,7 +724,7 @@
assertNotNull(message);
- assertEquals("aardvarks", message.getBuffer().readString());
+ assertEquals("aardvarks", message.getBodyBuffer().readString());
assertEquals(i, message.getIntProperty("count").intValue());
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/CoreClientOverHttpTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -65,7 +65,7 @@
{
ClientMessage message = session.createClientMessage(HornetQTextMessage.TYPE,
false, 0,
System.currentTimeMillis(), (byte) 1);
- message.getBuffer().writeString("CoreClientOverHttpTest");
+ message.getBodyBuffer().writeString("CoreClientOverHttpTest");
producer.send(message);
}
@@ -77,7 +77,7 @@
{
ClientMessage message2 = consumer.receive();
- assertEquals("CoreClientOverHttpTest",
message2.getBuffer().readString());
+ assertEquals("CoreClientOverHttpTest",
message2.getBodyBuffer().readString());
message2.acknowledge();
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -182,7 +182,6 @@
if (isXA)
{
-
session.end(xid, XAResource.TMSUCCESS);
session.prepare(xid);
@@ -349,7 +348,7 @@
else
{
- HornetQBuffer buffer = message.getBuffer();
+ HornetQBuffer buffer = message.getBodyBuffer();
buffer.resetReaderIndex();
assertEquals(numberOfBytes, buffer.writerIndex());
for (long b = 0; b < numberOfBytes; b++)
@@ -422,7 +421,7 @@
assertEquals(i, ((Integer)message.getObjectProperty(new
SimpleString("counter-message"))).intValue());
}
- HornetQBuffer buffer = message.getBuffer();
+ HornetQBuffer buffer = message.getBodyBuffer();
buffer.resetReaderIndex();
if (useStreamOnConsume)
@@ -571,7 +570,7 @@
{
bytes[j] = getSamplebyte(j);
}
- message.getBuffer().writeBytes(bytes);
+ message.getBodyBuffer().writeBytes(bytes);
}
message.putIntProperty(new SimpleString("counter-message"), i);
if (delayDelivery > 0)
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/ServerLargeMessageTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -19,7 +19,7 @@
import org.hornetq.core.client.ClientSession;
import org.hornetq.core.client.ClientSessionFactory;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
-import org.hornetq.core.persistence.impl.journal.FileLargeServerMessage;
+import org.hornetq.core.persistence.impl.journal.LargeServerMessageImpl;
import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.ServiceTestBase;
@@ -57,7 +57,7 @@
try
{
- FileLargeServerMessage fileMessage = new
FileLargeServerMessage((JournalStorageManager)server.getStorageManager());
+ LargeServerMessageImpl fileMessage = new
LargeServerMessageImpl((JournalStorageManager)server.getStorageManager());
fileMessage.setMessageID(1005);
@@ -90,7 +90,7 @@
for (int i = 0 ; i < 2 *
ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE; i++)
{
- assertEquals(getSamplebyte(i), msg.getBuffer().readByte());
+ assertEquals(getSamplebyte(i), msg.getBodyBuffer().readByte());
}
msg.acknowledge();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -359,7 +359,7 @@
for (int i = 0; i < NUMBER_MESSAGES_BEFORE_PAGING; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producer.send(msg);
}
session.commit();
@@ -368,21 +368,21 @@
assertEquals(0, addressControl.getNumberOfPages());
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producer.send(msg);
session.commit();
assertEquals(1, addressControl.getNumberOfPages());
msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producer.send(msg);
session.commit();
assertEquals(1, addressControl.getNumberOfPages());
msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[512]);
+ msg.getBodyBuffer().writeBytes(new byte[512]);
producer.send(msg);
session.commit();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -25,7 +25,9 @@
import junit.framework.TestCase;
import org.hornetq.core.buffers.HornetQChannelBuffers;
+import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.impl.ClientMessageImpl;
+import org.hornetq.core.client.impl.ClientSessionImpl;
import org.hornetq.core.client.management.impl.ManagementHelper;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.Message;
@@ -58,7 +60,7 @@
String operationName = randomString();
String param = randomString();
String[] params = new String[] { randomString(), randomString(), randomString() };
- Message msg = new ClientMessageImpl(false,
HornetQChannelBuffers.dynamicBuffer(1024));
+ Message msg = new ClientMessageImpl();
ManagementHelper.putOperationInvocation(msg, resource, operationName, param,
params);
Object[] parameters = ManagementHelper.retrieveOperationParameters(msg);
@@ -146,7 +148,8 @@
Object[] params = new Object[] { i, s, d, b, l, map, strArray, maps };
- Message msg = new ClientMessageImpl(false,
HornetQChannelBuffers.dynamicBuffer(1024));
+ Message msg = new ClientMessageImpl();
+ msg.setBuffer(HornetQChannelBuffers.dynamicBuffer(1024));
ManagementHelper.putOperationInvocation(msg, resource, operationName, params);
Object[] parameters = ManagementHelper.retrieveOperationParameters(msg);
@@ -212,7 +215,8 @@
Object[] params = new Object[] { "hello", map };
- Message msg = new ClientMessageImpl(false,
HornetQChannelBuffers.dynamicBuffer(1024));
+ Message msg = new ClientMessageImpl();
+ msg.setBuffer(HornetQChannelBuffers.dynamicBuffer(1024));
ManagementHelper.putOperationInvocation(msg, resource, operationName, params);
Object[] parameters = ManagementHelper.retrieveOperationParameters(msg);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/paging/PageCrashTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/paging/PageCrashTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/paging/PageCrashTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -151,7 +151,7 @@
ClientMessage message = null;
message = session.createClientMessage(true);
- message.getBuffer().writeBytes(new byte[1024]);
+ message.getBodyBuffer().writeBytes(new byte[1024]);
PagingStore store =
server.getPostOffice().getPagingManager().getPageStore(ADDRESS);
Deleted:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/persistence/JournalStorageManagerIntegrationTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/persistence/JournalStorageManagerIntegrationTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/persistence/JournalStorageManagerIntegrationTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -1,85 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.tests.integration.persistence;
-
-import java.util.concurrent.Executors;
-
-import org.hornetq.core.config.Configuration;
-import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
-import org.hornetq.core.server.JournalType;
-import org.hornetq.core.server.LargeServerMessage;
-import org.hornetq.core.server.ServerMessage;
-import org.hornetq.tests.util.ServiceTestBase;
-
-/**
- * A JournalStorageManagerIntegrationTest
- *
- * @author <a href="mailto:clebert.suconic@jboss.org">Clebert
Suconic</a>
- *
- * Created Jan 24, 2009 11:14:13 PM
- *
- *
- */
-public class JournalStorageManagerIntegrationTest extends ServiceTestBase
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testLargeMessageCopy() throws Exception
- {
- clearData();
-
- Configuration configuration = createDefaultConfig();
-
- configuration.start();
-
- configuration.setJournalType(JournalType.ASYNCIO);
-
- final JournalStorageManager journal = new JournalStorageManager(configuration,
Executors.newCachedThreadPool());
- journal.start();
-
- LargeServerMessage msg = journal.createLargeMessage();
- msg.setMessageID(1);
-
- byte[] data = new byte[1024];
-
- for (int i = 0; i < 110; i++)
- {
- msg.addBytes(data);
- }
-
- ServerMessage msg2 = msg.copy(2);
-
- assertEquals(110 * 1024, msg.getBodySize());
- assertEquals(110 * 1024, msg2.getBodySize());
-
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/DelayedMessageTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -112,7 +112,7 @@
assertNotNull(tm);
- assertEquals("message" + i, tm.getBuffer().readString());
+ assertEquals("message" + i, tm.getBodyBuffer().readString());
}
//Now close the session
@@ -176,7 +176,7 @@
{
ClientMessage tm = consumer2.receive(500);
assertNotNull(tm);
- assertEquals("message" + i, tm.getBuffer().readString());
+ assertEquals("message" + i, tm.getBodyBuffer().readString());
}
//Now rollback
@@ -231,7 +231,7 @@
{
ClientMessage tm = consumer2.receive(500);
assertNotNull(tm);
- assertEquals("message" + i, tm.getBuffer().readString());
+ assertEquals("message" + i, tm.getBodyBuffer().readString());
}
//Now rollback
@@ -265,7 +265,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(body);
+ message.getBodyBuffer().writeString(body);
return message;
}
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/scheduling/ScheduledMessageTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -149,7 +149,7 @@
ClientMessage message2 = consumer.receive(10250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message2.getBuffer().readString());
+ assertEquals("m1", message2.getBodyBuffer().readString());
message2.acknowledge();
@@ -183,8 +183,8 @@
session.start();
ClientMessage message3 = consumer.receive(1000);
ClientMessage message2 = consumer2.receive(1000);
- assertEquals("m1", message3.getBuffer().readString());
- assertEquals("m1", message2.getBuffer().readString());
+ assertEquals("m1", message3.getBodyBuffer().readString());
+ assertEquals("m1", message2.getBodyBuffer().readString());
long time = System.currentTimeMillis();
// force redelivery
consumer.close();
@@ -195,8 +195,8 @@
message2 = consumer2.receive(1000);
time += 5000;
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message3.getBuffer().readString());
- assertEquals("m1", message2.getBuffer().readString());
+ assertEquals("m1", message3.getBodyBuffer().readString());
+ assertEquals("m1", message2.getBodyBuffer().readString());
message2.acknowledge();
message3.acknowledge();
@@ -234,8 +234,8 @@
assertNotNull(message3);
ClientMessage message2 = consumer2.receive(1000);
assertNotNull(message2);
- assertEquals("m1", message3.getBuffer().readString());
- assertEquals("m1", message2.getBuffer().readString());
+ assertEquals("m1", message3.getBodyBuffer().readString());
+ assertEquals("m1", message2.getBodyBuffer().readString());
long time = System.currentTimeMillis();
// force redelivery
consumer.close();
@@ -257,8 +257,8 @@
assertNotNull(message2);
time += 5000;
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message3.getBuffer().readString());
- assertEquals("m1", message2.getBuffer().readString());
+ assertEquals("m1", message3.getBodyBuffer().readString());
+ assertEquals("m1", message2.getBodyBuffer().readString());
message2.acknowledge();
message3.acknowledge();
@@ -284,7 +284,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString("testINVMCoreClient");
+ message.getBodyBuffer().writeString("testINVMCoreClient");
message.setDurable(true);
long time = System.currentTimeMillis();
time += 10000;
@@ -309,7 +309,7 @@
ClientMessage message2 = consumer.receive(11000);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("testINVMCoreClient", message2.getBuffer().readString());
+ assertEquals("testINVMCoreClient",
message2.getBodyBuffer().readString());
message2.acknowledge();
@@ -370,27 +370,27 @@
ClientMessage message = consumer.receive(11000);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message.getBuffer().readString());
+ assertEquals("m1", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m2", message.getBuffer().readString());
+ assertEquals("m2", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m3", message.getBuffer().readString());
+ assertEquals("m3", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m4", message.getBuffer().readString());
+ assertEquals("m4", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m5", message.getBuffer().readString());
+ assertEquals("m5", message.getBodyBuffer().readString());
message.acknowledge();
// Make sure no more messages
@@ -451,27 +451,27 @@
ClientMessage message = consumer.receive(10250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message.getBuffer().readString());
+ assertEquals("m1", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m3", message.getBuffer().readString());
+ assertEquals("m3", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m5", message.getBuffer().readString());
+ assertEquals("m5", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m2", message.getBuffer().readString());
+ assertEquals("m2", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m4", message.getBuffer().readString());
+ assertEquals("m4", message.getBodyBuffer().readString());
message.acknowledge();
// Make sure no more messages
@@ -526,24 +526,24 @@
session.start();
ClientMessage message = consumer.receive(1000);
- assertEquals("m2", message.getBuffer().readString());
+ assertEquals("m2", message.getBodyBuffer().readString());
message.acknowledge();
message = consumer.receive(1000);
- assertEquals("m4", message.getBuffer().readString());
+ assertEquals("m4", message.getBodyBuffer().readString());
message.acknowledge();
message = consumer.receive(10250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m1", message.getBuffer().readString());
+ assertEquals("m1", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m3", message.getBuffer().readString());
+ assertEquals("m3", message.getBodyBuffer().readString());
message.acknowledge();
time += 1000;
message = consumer.receive(1250);
assertTrue(System.currentTimeMillis() >= time);
- assertEquals("m5", message.getBuffer().readString());
+ assertEquals("m5", message.getBodyBuffer().readString());
message.acknowledge();
// Make sure no more messages
@@ -593,7 +593,7 @@
System.out.println("elapsed time = " + (end - time));
assertTrue(end >= time);
assertNotNull(message2);
- assertEquals("testINVMCoreClient", message2.getBuffer().readString());
+ assertEquals("testINVMCoreClient",
message2.getBodyBuffer().readString());
message2.acknowledge();
session.end(xid2, XAResource.TMSUCCESS);
@@ -698,25 +698,25 @@
ClientMessage rm1 = consumer.receive(250);
assertNotNull(rm1);
- assertEquals("testScheduled2", rm1.getBuffer().readString());
+ assertEquals("testScheduled2", rm1.getBodyBuffer().readString());
ClientMessage rm2 = consumer.receive(250);
assertNotNull(rm2);
- assertEquals("testScheduled3", rm2.getBuffer().readString());
+ assertEquals("testScheduled3", rm2.getBodyBuffer().readString());
ClientMessage rm3 = consumer.receive(250);
assertNotNull(rm3);
- assertEquals("testScheduled4", rm3.getBuffer().readString());
+ assertEquals("testScheduled4", rm3.getBodyBuffer().readString());
//Now the one with a scheduled with a -ve number
ClientMessage rm5 = consumer.receive(250);
assertNotNull(rm5);
- assertEquals("testScheduled9", rm5.getBuffer().readString());
+ assertEquals("testScheduled9", rm5.getBodyBuffer().readString());
//Now the scheduled
ClientMessage rm6 = consumer.receive(3250);
assertNotNull(rm6);
- assertEquals("testScheduled7", rm6.getBuffer().readString());
+ assertEquals("testScheduled7", rm6.getBodyBuffer().readString());
long now2 = System.currentTimeMillis();
@@ -724,7 +724,7 @@
ClientMessage rm7 = consumer.receive(1250);
assertNotNull(rm7);
- assertEquals("testScheduled6", rm7.getBuffer().readString());
+ assertEquals("testScheduled6", rm7.getBodyBuffer().readString());
now2 = System.currentTimeMillis();
@@ -732,7 +732,7 @@
ClientMessage rm8 = consumer.receive(1250);
assertNotNull(rm8);
- assertEquals("testScheduled5", rm8.getBuffer().readString());
+ assertEquals("testScheduled5", rm8.getBodyBuffer().readString());
now2 = System.currentTimeMillis();
@@ -740,7 +740,7 @@
ClientMessage rm9 = consumer.receive(1250);
assertNotNull(rm9);
- assertEquals("testScheduled8", rm9.getBuffer().readString());
+ assertEquals("testScheduled8", rm9.getBodyBuffer().readString());
now2 = System.currentTimeMillis();
@@ -748,7 +748,7 @@
ClientMessage rm10 = consumer.receive(1250);
assertNotNull(rm10);
- assertEquals("testScheduled1", rm10.getBuffer().readString());
+ assertEquals("testScheduled1", rm10.getBodyBuffer().readString());
now2 = System.currentTimeMillis();
@@ -772,7 +772,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(body);
+ message.getBodyBuffer().writeString(body);
return message;
}
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/security/SimpleClient.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/security/SimpleClient.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/security/SimpleClient.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -65,7 +65,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(messageText);
+ message.getBodyBuffer().writeString(messageText);
producer.send(message);
session.start();
@@ -76,7 +76,7 @@
throw new Exception("did not receive the message");
}
- String text = receivedMsg.getBuffer().readString();
+ String text = receivedMsg.getBodyBuffer().readString();
if (text == null || !text.equals(messageText))
{
throw new Exception("received " + text + ", was expecting
" + messageText);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/ExpiryRunnerTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/ExpiryRunnerTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/ExpiryRunnerTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -131,7 +131,7 @@
ClientMessage cm = consumer.receive(500);
assertNotNull("message not received " + i, cm);
cm.acknowledge();
- assertEquals("m" + i, cm.getBuffer().readString());
+ assertEquals("m" + i, cm.getBodyBuffer().readString());
}
consumer.close();
Thread.sleep(2100);
@@ -208,7 +208,7 @@
{
break;
}
- String text = cm.getBuffer().readString();
+ String text = cm.getBodyBuffer().readString();
cm.acknowledge();
assertFalse(dummyMessageHandler.payloads.contains(text));
dummyMessageHandler.payloads.add(text);
@@ -327,7 +327,7 @@
break;
}
message.acknowledge();
- payloads.add(message.getBuffer().readString());
+ payloads.add(message.getBodyBuffer().readString());
Thread.sleep(110);
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQRecoveryTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQRecoveryTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQRecoveryTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -53,7 +53,7 @@
public void testMultipleMessagesAfterRecovery() throws Exception
{
Xid xid = new XidImpl("bq1".getBytes(), 4,
"gtid1".getBytes());
- ClientProducer producer = clientSessionXa.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSessionXa.createProducer(address);
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
clientSessionXa.start(xid, XAResource.TMNOFLAGS);
@@ -82,17 +82,17 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testManyMessagesReceivedWithRollback() throws Exception
{
Xid xid = new XidImpl("bq1".getBytes(), 4,
"gtid1".getBytes());
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSessionXa.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
@@ -119,27 +119,27 @@
producer.send(m1);
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
producer.send(m2);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
producer.send(m3);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
producer.send(m4);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
producer.send(m5);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
producer.send(m6);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
clientSessionXa.end(xid, XAResource.TMSUCCESS);
clientSessionXa.prepare(xid);
@@ -153,7 +153,7 @@
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = consumer.receiveImmediate();
assertNull(m);
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/server/LVQTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -50,7 +50,7 @@
public void testSimple() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
ClientMessage m1 = createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
@@ -63,12 +63,12 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
}
public void testMultipleMessages() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
@@ -88,16 +88,16 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testFirstMessageReceivedButAckedAfter() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
ClientMessage m1 = createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
@@ -110,16 +110,16 @@
assertNotNull(m);
producer.send(m2);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
}
public void testFirstMessageReceivedAndCancelled() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
ClientMessage m1 = createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
@@ -130,13 +130,13 @@
clientSession.start();
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
producer.send(m2);
consumer.close();
consumer = clientSession.createConsumer(qName1);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals("m2", m.getBuffer().readString());
+ assertEquals("m2", m.getBodyBuffer().readString());
m.acknowledge();
m = consumer.receiveImmediate();
assertNull(m);
@@ -144,7 +144,7 @@
public void testManyMessagesReceivedAndCancelled() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
@@ -164,33 +164,33 @@
producer.send(m1);
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
producer.send(m2);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
producer.send(m3);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
producer.send(m4);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
producer.send(m5);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
producer.send(m6);
m = consumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
consumer.close();
consumer = clientSession.createConsumer(qName1);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = consumer.receiveImmediate();
assertNull(m);
}
@@ -198,7 +198,7 @@
public void testSimpleInTx() throws Exception
{
- ClientProducer producer = clientSessionTxReceives.createProducer(address, -1, true,
true);
+ ClientProducer producer = clientSessionTxReceives.createProducer(address);
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
ClientMessage m1 = createTextMessage("m1", clientSession);
SimpleString rh = new SimpleString("SMID1");
@@ -211,12 +211,12 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
}
public void testMultipleMessagesInTx() throws Exception
{
- ClientProducer producer = clientSessionTxReceives.createProducer(address, -1, true,
true);
+ ClientProducer producer = clientSessionTxReceives.createProducer(address);
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
@@ -236,11 +236,11 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSessionTxReceives.commit();
m = consumer.receiveImmediate();
assertNull(m);
@@ -248,7 +248,7 @@
public void testMultipleMessagesInTxRollback() throws Exception
{
- ClientProducer producer = clientSessionTxReceives.createProducer(address, -1, true,
true);
+ ClientProducer producer = clientSessionTxReceives.createProducer(address);
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
SimpleString messageId1 = new SimpleString("SMID1");
SimpleString messageId2 = new SimpleString("SMID2");
@@ -266,35 +266,35 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
producer.send(m3);
producer.send(m4);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSessionTxReceives.rollback();
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testMultipleMessagesInTxSend() throws Exception
{
- ClientProducer producer = clientSessionTxSends.createProducer(address, -1, true,
true);
+ ClientProducer producer = clientSessionTxSends.createProducer(address);
ClientConsumer consumer = clientSessionTxSends.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
ClientMessage m1 = createTextMessage("m1", clientSession);
@@ -320,12 +320,12 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
}
public void testMultipleMessagesPersistedCorrectly() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
ClientMessage m1 = createTextMessage("m1", clientSession);
@@ -356,14 +356,14 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = consumer.receiveImmediate();
assertNull(m);
}
public void testMultipleMessagesPersistedCorrectlyInTx() throws Exception
{
- ClientProducer producer = clientSessionTxSends.createProducer(address, -1, true,
true);
+ ClientProducer producer = clientSessionTxSends.createProducer(address);
ClientConsumer consumer = clientSessionTxSends.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
ClientMessage m1 = createTextMessage("m1", clientSession);
@@ -395,14 +395,14 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = consumer.receiveImmediate();
assertNull(m);
}
public void testMultipleAcksPersistedCorrectly() throws Exception
{
- ClientProducer producer = clientSession.createProducer(address, -1, true, true);
+ ClientProducer producer = clientSession.createProducer(address);
ClientConsumer consumer = clientSession.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
ClientMessage m1 = createTextMessage("m1", clientSession);
@@ -428,37 +428,37 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
producer.send(m2);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
producer.send(m3);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
producer.send(m4);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
producer.send(m5);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
producer.send(m6);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
}
public void testMultipleAcksPersistedCorrectlyInTx() throws Exception
{
- ClientProducer producer = clientSessionTxReceives.createProducer(address, -1, true,
true);
+ ClientProducer producer = clientSessionTxReceives.createProducer(address);
ClientConsumer consumer = clientSessionTxReceives.createConsumer(qName1);
SimpleString rh = new SimpleString("SMID1");
ClientMessage m1 = createTextMessage("m1", clientSession);
@@ -484,32 +484,32 @@
ClientMessage m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
producer.send(m2);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
producer.send(m3);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
producer.send(m4);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
producer.send(m5);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
producer.send(m6);
m = consumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
clientSessionTxReceives.commit();
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -67,7 +67,7 @@
ClientMessage message = session.createClientMessage(HornetQTextMessage.TYPE,
false, 0,
System.currentTimeMillis(), (byte) 1);
-
message.getBuffer().writeString(CoreClientOverSSLTest.MESSAGE_TEXT_FROM_CLIENT);
+
message.getBodyBuffer().writeString(CoreClientOverSSLTest.MESSAGE_TEXT_FROM_CLIENT);
producer.send(message);
session.close();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaRecoveryTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaRecoveryTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaRecoveryTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -508,16 +508,16 @@
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testBasicSendWithRollback(final boolean stopServer) throws Exception
@@ -611,16 +611,16 @@
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
}
public void testMultipleTxSendWithCommit(final boolean stopServer) throws Exception
@@ -673,28 +673,28 @@
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testMultipleTxSendWithRollback(final boolean stopServer) throws Exception
@@ -799,16 +799,16 @@
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
m = clientConsumer.receiveImmediate();
assertNull(m);
}
@@ -862,28 +862,28 @@
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
}
public void testBasicReceiveWithCommit(final boolean stopServer) throws Exception
@@ -905,19 +905,19 @@
ClientMessage m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
assertEquals("Expected XA_OK", XAResource.XA_OK,
clientSession.prepare(xid));
@@ -963,19 +963,19 @@
ClientMessage m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
@@ -1004,16 +1004,16 @@
clientSession.start();
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testMultipleTxReceiveWithCommit(final boolean stopServer) throws
Exception
@@ -1049,19 +1049,19 @@
ClientMessage m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = clientConsumer2.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
clientSession2.end(xid2, XAResource.TMSUCCESS);
clientSession2.prepare(xid2);
clientSession2.close();
@@ -1071,19 +1071,19 @@
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
@@ -1139,19 +1139,19 @@
ClientMessage m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = clientConsumer2.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = clientConsumer2.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
clientSession2.end(xid2, XAResource.TMSUCCESS);
clientSession2.prepare(xid2);
clientSession2.close();
@@ -1161,19 +1161,19 @@
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
@@ -1195,19 +1195,19 @@
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
protected void stopAndRestartServer() throws Exception
@@ -1250,7 +1250,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(s);
+ message.getBodyBuffer().writeString(s);
return message;
}
@@ -1261,7 +1261,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeBytes(b);
+ message.getBodyBuffer().writeBytes(b);
return message;
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/BasicXaTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -163,16 +163,16 @@
ClientConsumer clientConsumer = clientSession.createConsumer(atestq);
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
}
public void testReceivePrepareDoesntRollbackOnClose() throws Exception
@@ -196,19 +196,19 @@
ClientMessage m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/XaTimeoutTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/XaTimeoutTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/xa/XaTimeoutTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -178,19 +178,19 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
CountDownLatch latch = new CountDownLatch(1);
messagingService.getResourceManager().getTransaction(xid).addOperation(new
RollbackCompleteOperation(latch));
@@ -211,19 +211,19 @@
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = consumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession2.close();
}
@@ -256,19 +256,19 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
CountDownLatch latch = new CountDownLatch(1);
messagingService.getResourceManager().getTransaction(xid).addOperation(new
RollbackCompleteOperation(latch));
@@ -289,19 +289,19 @@
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = consumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
m = consumer.receiveImmediate();
assertNull(m);
clientSession2.close();
@@ -336,19 +336,19 @@
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
clientSession.prepare(xid);
CountDownLatch latch = new CountDownLatch(1);
@@ -364,19 +364,19 @@
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m5");
+ assertEquals(m.getBodyBuffer().readString(), "m5");
m = consumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m6");
+ assertEquals(m.getBodyBuffer().readString(), "m6");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m7");
+ assertEquals(m.getBodyBuffer().readString(), "m7");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m8");
+ assertEquals(m.getBodyBuffer().readString(), "m8");
m = consumer.receiveImmediate();
assertNull(m);
clientSession2.close();
@@ -440,19 +440,19 @@
clientSession2.start();
ClientMessage m = consumer.receive(500);
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m1");
+ assertEquals(m.getBodyBuffer().readString(), "m1");
m = consumer.receive(500);
assertNotNull(m);
m.acknowledge();
- assertEquals(m.getBuffer().readString(), "m2");
+ assertEquals(m.getBodyBuffer().readString(), "m2");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m3");
+ assertEquals(m.getBodyBuffer().readString(), "m3");
m = consumer.receive(500);
m.acknowledge();
assertNotNull(m);
- assertEquals(m.getBuffer().readString(), "m4");
+ assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession2.close();
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/performance/paging/MeasurePagingMultiThreadTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/performance/paging/MeasurePagingMultiThreadTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/performance/paging/MeasurePagingMultiThreadTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -101,7 +101,7 @@
session = factory.createSession(false, true, true);
producer = session.createProducer(adr);
msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[SIZE_OF_MESSAGE]);
+ msg.getBodyBuffer().writeBytes(new byte[SIZE_OF_MESSAGE]);
}
// run is not going to close sessions or anything, as we don't want to
measure that time
@@ -202,7 +202,7 @@
ClientProducer producer = session.createProducer(adr);
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[messageSize]);
+ msg.getBodyBuffer().writeBytes(new byte[messageSize]);
sendMessages(nMessages, producer, msg);
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/performance/persistence/StorageManagerTimingTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -167,11 +167,7 @@
final SimpleString address = new SimpleString("Destination "
+ i);
- ServerMessageImpl implMsg = new ServerMessageImpl(/* type */(byte)1, /*
durable */
- true, /* expiration */
- 0,
- /* timestamp */0, /* priority */
- (byte)0, HornetQChannelBuffers.wrappedBuffer(new byte[1024]));
+ ServerMessageImpl implMsg = new ServerMessageImpl();
implMsg.putStringProperty(new SimpleString("Key"), new
SimpleString("This String is worthless!"));
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -115,7 +115,7 @@
for (int j = 0; j < 1000; j++)
{
Message msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[1024]);
+ msg.getBodyBuffer().writeBytes(new byte[1024]);
prod.send(msg);
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -303,7 +303,7 @@
for (int i = 0; i < nmessages; i++)
{
ClientMessage msg = session.createClientMessage(true);
- msg.getBuffer().writeBytes(new byte[1024]);
+ msg.getBodyBuffer().writeBytes(new byte[1024]);
prod.send(msg);
}
session.commit();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -34,7 +34,7 @@
import org.hornetq.core.client.impl.LargeMessageBufferImpl;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveContinuationMessage;
-import org.hornetq.core.remoting.impl.wireformat.SessionReceiveMessage;
+import org.hornetq.core.remoting.impl.wireformat.SessionReceiveLargeMessage;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
import org.hornetq.utils.SimpleString;
@@ -552,232 +552,158 @@
static class FakeConsumerInternal implements ClientConsumerInternal
{
- public void clearAtFailover()
+
+ public void close() throws HornetQException
{
// TODO Auto-generated method stub
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.client.impl.ClientConsumerInternal#acknowledge(org.hornetq.core.client.ClientMessage)
- */
- public void acknowledge(ClientMessage message) throws HornetQException
+ public Exception getLastException()
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#cleanUp()
- */
- public void cleanUp() throws HornetQException
+ public MessageHandler getMessageHandler() throws HornetQException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#clear()
- */
- public void clear()
+ public boolean isClosed()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#flowControl(int,
boolean)
- */
- public void flowControl(int messageBytes, boolean isLargeMessage) throws
HornetQException
+ public ClientMessage receive() throws HornetQException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#flushAcks()
- */
- public void flushAcks() throws HornetQException
+ public ClientMessage receive(long timeout) throws HornetQException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#getBufferSize()
- */
- public int getBufferSize()
+ public ClientMessage receiveImmediate() throws HornetQException
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#getClientWindowSize()
- */
- public int getClientWindowSize()
+ public void setMessageHandler(MessageHandler handler) throws HornetQException
{
-
- return 0;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#getID()
- */
- public long getID()
+ public void acknowledge(ClientMessage message) throws HornetQException
{
-
- return 0;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.client.impl.ClientConsumerInternal#handleLargeMessage(org.hornetq.core.remoting.impl.wireformat.SessionReceiveMessage)
- */
- public void handleLargeMessage(SessionReceiveMessage largeMessageHeader) throws
Exception
+ public void cleanUp() throws HornetQException
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.client.impl.ClientConsumerInternal#handleLargeMessageContinuation(org.hornetq.core.remoting.impl.wireformat.SessionReceiveContinuationMessage)
- */
- public void handleLargeMessageContinuation(SessionReceiveContinuationMessage
continuation) throws Exception
+ public void clear() throws HornetQException
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.client.impl.ClientConsumerInternal#handleMessage(org.hornetq.core.client.impl.ClientMessageInternal)
- */
- public void handleMessage(ClientMessageInternal message) throws Exception
+ public void clearAtFailover()
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#isFileConsumer()
- */
- public boolean isFileConsumer()
+ public void flowControl(int messageBytes, boolean discountSlowConsumer) throws
HornetQException
{
-
- return false;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#start()
- */
- public void start()
+ public void flushAcks() throws HornetQException
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.impl.ClientConsumerInternal#stop()
- */
- public void stop() throws HornetQException
+ public int getBufferSize()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#close()
- */
- public void close() throws HornetQException
+ public int getClientWindowSize()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#getLastException()
- */
- public Exception getLastException()
+ public SimpleString getFilterString()
{
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#getMessageHandler()
- */
- public MessageHandler getMessageHandler() throws HornetQException
+ public long getID()
{
-
- return null;
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#isClosed()
- */
- public boolean isClosed()
+ public SimpleString getQueueName()
{
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#receive()
- */
- public ClientMessage receive() throws HornetQException
- {
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#receive(long)
- */
- public ClientMessage receive(long timeout) throws HornetQException
+ public void handleLargeMessage(SessionReceiveLargeMessage largeMessageHeader)
throws Exception
{
-
- return null;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#receiveImmediate()
- */
- public ClientMessage receiveImmediate() throws HornetQException
+ public void handleLargeMessageContinuation(SessionReceiveContinuationMessage
continuation) throws Exception
{
-
- return null;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.client.ClientConsumer#setMessageHandler(org.hornetq.core.client.MessageHandler)
- */
- public void setMessageHandler(MessageHandler handler) throws HornetQException
+ public void handleMessage(ClientMessageInternal message) throws Exception
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.client.ClientConsumer#getLargeMessageCacheDir()
- */
- public File getLargeMessageCacheDir()
+ public boolean isBrowseOnly()
{
- return null;
- }
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.client.ClientConsumer#setLargeMessageCacheDir(java.io.File)
- */
- public void setLargeMessageCacheDir(File largeMessageCacheDir)
- {
- }
-
- public SimpleString getFilterString()
- {
// TODO Auto-generated method stub
- return null;
+ return false;
}
- public SimpleString getQueueName()
+ public void start()
{
// TODO Auto-generated method stub
- return null;
+
}
- public boolean isBrowseOnly()
+ public void stop() throws HornetQException
{
// TODO Auto-generated method stub
- return false;
+
}
+
-
}
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -43,31 +43,7 @@
public class MessageImplTest extends UnitTestCase
{
private static final Logger log = Logger.getLogger(MessageImplTest.class);
-
- public void testEncodeDecode()
- {
- for (int j = 0; j < 10; j++)
- {
- byte[] bytes = new byte[1000];
- for (int i = 0; i < bytes.length; i++)
- {
- bytes[i] = randomByte();
- }
- HornetQBuffer body = HornetQChannelBuffers.wrappedBuffer(bytes);
- Message message1 = new ClientMessageImpl(randomByte(), randomBoolean(),
randomLong(), randomLong(), randomByte(), body);
- Message message = message1;
- message.setDestination(new SimpleString("oasoas"));
-
- message.putStringProperty(new SimpleString("prop1"), new
SimpleString("blah1"));
- message.putStringProperty(new SimpleString("prop2"), new
SimpleString("blah2"));
- HornetQBuffer buffer = HornetQChannelBuffers.buffer(message.getEncodeSize());
- message.encode(buffer);
- Message message2 = new ClientMessageImpl(false);
- message2.decodeHeadersAndProperties(buffer);
- assertMessagesEquivalent(message, message2);
- }
- }
-
+
public void getSetAttributes()
{
for (int j = 0; j < 10; j++)
@@ -116,13 +92,13 @@
assertEquals(priority2, message.getPriority());
message.setBuffer(body);
- assertTrue(body == message.getBuffer());
+ assertTrue(body == message.getBodyBuffer());
}
}
public void testExpired()
{
- Message message = new ClientMessageImpl(false);
+ Message message = new ClientMessageImpl();
assertEquals(0, message.getExpiration());
assertFalse(message.isExpired());
@@ -141,34 +117,12 @@
}
- public void testEncodingMessage() throws Exception
- {
-
- SimpleString address = new SimpleString("Simple Destination ");
-
- Message msg = new ClientMessageImpl(false);
-
- byte[] bytes = new byte[]{(byte)1, (byte)2, (byte)3};
- msg.setBuffer(HornetQChannelBuffers.wrappedBuffer(bytes));
-
- msg.setDestination(address);
- msg.putStringProperty(new SimpleString("Key"), new
SimpleString("This String is worthless!"));
- msg.putStringProperty(new SimpleString("Key"), new
SimpleString("This String is worthless and bigger!"));
- msg.putStringProperty(new SimpleString("Key2"), new
SimpleString("This String is worthless and bigger and bigger!"));
- msg.removeProperty(new SimpleString("Key2"));
-
- checkSizes(msg, new ServerMessageImpl());
-
- msg.removeProperty(new SimpleString("Key"));
-
- checkSizes(msg, new ServerMessageImpl());
- }
public void testProperties()
{
for (int j = 0; j < 10; j++)
{
- Message msg = new ClientMessageImpl(false);
+ Message msg = new ClientMessageImpl();
SimpleString prop1 = new SimpleString("prop1");
boolean val1 = randomBoolean();
@@ -300,7 +254,7 @@
assertEquals(msg1.getType(), msg2.getType());
- assertEqualsByteArrays(msg1.getBuffer().array(), msg2.getBuffer().array());
+ assertEqualsByteArrays(msg1.getBodyBuffer().array(), msg2.getBodyBuffer().array());
assertEquals(msg1.getDestination(), msg2.getDestination());
@@ -321,23 +275,5 @@
}
// Private
----------------------------------------------------------------------------------
-
- private void checkSizes(final Message obj, final EncodingSupport newObject)
- {
- HornetQBuffer buffer = HornetQChannelBuffers.buffer(1024);
- obj.encode(buffer);
- assertEquals (buffer.writerIndex(), obj.getEncodeSize());
- int originalSize = buffer.writerIndex();
- buffer.resetReaderIndex();
- newObject.decode(buffer);
-
-
- HornetQBuffer newBuffer = HornetQChannelBuffers.buffer(1024);
-
- newObject.encode(newBuffer);
-
- assertEquals(newObject.getEncodeSize(), newBuffer.writerIndex());
- assertEquals(originalSize, newBuffer.writerIndex());
- }
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -109,7 +109,7 @@
assertEquals(simpleDestination,
(msgs.get(i).getMessage(null)).getDestination());
- assertEqualsByteArrays(buffers.get(i).array(),
(msgs.get(i).getMessage(null)).getBuffer().array());
+ assertEqualsByteArrays(buffers.get(i).array(),
(msgs.get(i).getMessage(null)).getBodyBuffer().array());
}
impl.delete();
@@ -182,7 +182,7 @@
assertEquals(simpleDestination,
(msgs.get(i).getMessage(null)).getDestination());
- assertEqualsByteArrays(buffers.get(i).array(),
(msgs.get(i).getMessage(null)).getBuffer().array());
+ assertEqualsByteArrays(buffers.get(i).array(),
(msgs.get(i).getMessage(null)).getBodyBuffer().array());
}
impl.delete();
@@ -218,12 +218,7 @@
buffers.add(buffer);
- ServerMessage msg = new ServerMessageImpl((byte)1,
- true,
- 0,
- System.currentTimeMillis(),
- (byte)0,
- buffer);
+ ServerMessage msg = new ServerMessageImpl();
msg.setMessageID(i);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -90,7 +90,7 @@
assertEquals(1, msgs.size());
- assertEqualsByteArrays(msg.getBuffer().array(),
(msgs.get(0).getMessage(null)).getBuffer().array());
+ assertEqualsByteArrays(msg.getBodyBuffer().array(),
(msgs.get(0).getMessage(null)).getBodyBuffer().array());
assertTrue(store.isPaging());
@@ -112,12 +112,7 @@
protected ServerMessage createMessage(final long messageId, final SimpleString
destination, final ByteBuffer buffer)
{
- ServerMessage msg = new ServerMessageImpl((byte)1,
- true,
- 0,
- System.currentTimeMillis(),
- (byte)0,
- HornetQChannelBuffers.wrappedBuffer(new
byte[1024]));
+ ServerMessage msg = new ServerMessageImpl();
msg.setMessageID(messageId);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -295,7 +295,7 @@
for (int i = 0; i < 10; i++)
{
assertEquals(0, msg.get(i).getMessage(null).getMessageID());
- assertEqualsByteArrays(buffers.get(i).array(),
msg.get(i).getMessage(null).getBuffer().array());
+ assertEqualsByteArrays(buffers.get(i).array(),
msg.get(i).getMessage(null).getBodyBuffer().array());
}
}
@@ -366,7 +366,7 @@
for (int i = 0; i < 5; i++)
{
assertEquals(0, msg.get(i).getMessage(null).getMessageID());
- assertEqualsByteArrays(buffers.get(pageNr * 5 + i).array(),
msg.get(i).getMessage(null).getBuffer().array());
+ assertEqualsByteArrays(buffers.get(pageNr * 5 + i).array(),
msg.get(i).getMessage(null).getBodyBuffer().array());
}
}
@@ -410,7 +410,7 @@
assertEquals(0l, msgs.get(0).getMessage(null).getMessageID());
- assertEqualsByteArrays(buffers.get(0).array(),
msgs.get(0).getMessage(null).getBuffer().array());
+ assertEqualsByteArrays(buffers.get(0).array(),
msgs.get(0).getMessage(null).getBodyBuffer().array());
assertEquals(1, storeImpl.getNumberOfPages());
@@ -589,14 +589,14 @@
for (PagedMessage msg : msgs)
{
- long id = msg.getMessage(null).getBuffer().readLong();
- msg.getMessage(null).getBuffer().resetReaderIndex();
+ long id = msg.getMessage(null).getBodyBuffer().readLong();
+ msg.getMessage(null).getBodyBuffer().resetReaderIndex();
ServerMessage msgWritten = buffers.remove(id);
buffers2.put(id, msg.getMessage(null));
assertNotNull(msgWritten);
assertEquals(msg.getMessage(null).getDestination(),
msgWritten.getDestination());
- assertEqualsByteArrays(msgWritten.getBuffer().array(),
msg.getMessage(null).getBuffer().array());
+ assertEqualsByteArrays(msgWritten.getBodyBuffer().array(),
msg.getMessage(null).getBodyBuffer().array());
}
}
@@ -662,11 +662,11 @@
for (PagedMessage msg : msgs)
{
- long id = msg.getMessage(null).getBuffer().readLong();
+ long id = msg.getMessage(null).getBodyBuffer().readLong();
ServerMessage msgWritten = buffers2.remove(id);
assertNotNull(msgWritten);
assertEquals(msg.getMessage(null).getDestination(),
msgWritten.getDestination());
- assertEqualsByteArrays(msgWritten.getBuffer().array(),
msg.getMessage(null).getBuffer().array());
+ assertEqualsByteArrays(msgWritten.getBodyBuffer().array(),
msg.getMessage(null).getBodyBuffer().array());
}
}
@@ -675,9 +675,9 @@
lastPage.close();
assertEquals(1, lastMessages.size());
- lastMessages.get(0).getMessage(null).getBuffer().resetReaderIndex();
- assertEquals(lastMessages.get(0).getMessage(null).getBuffer().readLong(),
lastMessageId);
- assertEqualsByteArrays(lastMessages.get(0).getMessage(null).getBuffer().array(),
lastMsg.getBuffer().array());
+ lastMessages.get(0).getMessage(null).getBodyBuffer().resetReaderIndex();
+ assertEquals(lastMessages.get(0).getMessage(null).getBodyBuffer().readLong(),
lastMessageId);
+
assertEqualsByteArrays(lastMessages.get(0).getMessage(null).getBodyBuffer().array(),
lastMsg.getBodyBuffer().array());
assertEquals(0, buffers2.size());
@@ -706,7 +706,7 @@
final SimpleString destination,
final HornetQBuffer buffer)
{
- ServerMessage msg = new ServerMessageImpl((byte)1, true, 0,
System.currentTimeMillis(), (byte)0, buffer);
+ ServerMessage msg = new ServerMessageImpl();
msg.setDestination(destination);
@@ -1232,6 +1232,12 @@
{
}
+ public void storeReference(long queueID, long messageID, boolean last) throws
Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
class FakeStoreFactory implements PagingStoreFactory
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -285,864 +285,613 @@
class FakeMessage implements ServerMessage
{
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#makeCopyForExpiryOrDLA(long,
boolean)
- */
- public ServerMessage makeCopyForExpiryOrDLA(long newID, boolean expiry) throws
Exception
+ public ServerMessage copy() throws Exception
{
// TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.server.ServerMessage#setOriginalHeaders(org.hornetq.core.server.ServerMessage,
boolean)
- */
- public void setOriginalHeaders(ServerMessage other, boolean expiry)
+ public ServerMessage copy(long newID) throws Exception
{
// TODO Auto-generated method stub
-
+ return null;
}
- public Map<String, Object> toMap()
+ public MessageReference createReference(Queue queue)
{
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#copy(long)
- */
- public ServerMessage copy(final long newID) throws Exception
+ public int decrementDurableRefCount()
{
-
- return null;
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#copy()
- */
- public ServerMessage copy() throws Exception
+ public int decrementRefCount(MessageReference reference) throws Exception
{
-
- return null;
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.server.ServerMessage#createReference(org.hornetq.core.server.Queue)
- */
- public MessageReference createReference(final Queue queue)
+ public void encodeMessageIDToBuffer()
{
-
- return null;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#decrementDurableRefCount()
- */
- public int decrementDurableRefCount()
+ public int getEndMessagePosition()
{
-
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#decrementRefCount()
- */
- public int decrementRefCount()
+ public int getMemoryEstimate()
{
-
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#getMemoryEstimate()
- */
- public int getMemoryEstimate()
+ public PagingStore getPagingStore()
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#getRefCount()
- */
public int getRefCount()
{
-
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#incrementDurableRefCount()
- */
public int incrementDurableRefCount()
{
-
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#incrementRefCount()
- */
- public int incrementRefCount()
+ public int incrementRefCount(MessageReference reference) throws Exception
{
-
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#isLargeMessage()
- */
- public boolean isLargeMessage()
+ public ServerMessage makeCopyForExpiryOrDLA(long newID, boolean expiry) throws
Exception
{
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public boolean page(boolean duplicateDetection) throws Exception
+ {
+ // TODO Auto-generated method stub
return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#isStored()
- */
- public boolean isStored()
+ public boolean page(long transactionID, boolean duplicateDetection) throws
Exception
{
-
+ // TODO Auto-generated method stub
return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#setMessageID(long)
- */
- public void setMessageID(final long id)
+ public void setEndMessagePosition(int pos)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.ServerMessage#setStored()
- */
- public void setStored()
+ public void setMessageID(long id)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#containsProperty(org.hornetq.utils.SimpleString)
- */
- public boolean containsProperty(final SimpleString key)
+ public void setNeedsEncoding()
{
-
- return false;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#decode(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void decode(final HornetQBuffer buffer)
+ public void setOriginalHeaders(ServerMessage other, boolean expiry)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#decodeBody(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void decodeBody(final HornetQBuffer buffer)
+ public void setPagingStore(PagingStore store)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#decodeProperties(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void decodeHeadersAndProperties(final HornetQBuffer buffer)
+ public boolean storeIsPaging()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#encode(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void encode(final HornetQBuffer buffer)
+ public void afterSend()
{
-
+ // TODO Auto-generated method stub
+
}
- public void encodeBody(HornetQBuffer bufferOut, BodyEncoder context, int size)
+ public boolean containsProperty(SimpleString key)
{
- // To change body of implemented methods use File | Settings | File Templates.
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#encodeBody(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void encodeBody(final HornetQBuffer buffer)
+ public boolean containsProperty(String key)
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#encodeProperties(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void encodeHeadersAndProperties(final HornetQBuffer buffer)
+ public void decodeFromWire(HornetQBuffer buffer)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBody()
- */
- public HornetQBuffer getBuffer()
+ public void decodeHeadersAndProperties(HornetQBuffer buffer)
{
-
- return null;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBodySize()
- */
- public int getBodySize()
+ public void encodeHeadersAndProperties(HornetQBuffer buffer)
{
-
- return 0;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getDestination()
- */
- public SimpleString getDestination()
+ public HornetQBuffer getBodyBuffer()
{
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getEncodeSize()
- */
- public int getEncodeSize()
+ public BodyEncoder getBodyEncoder()
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getExpiration()
- */
- public long getExpiration()
+ public InputStream getBodyInputStream()
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getMessageID()
- */
- public long getMessageID()
+ public Boolean getBooleanProperty(SimpleString key) throws
PropertyConversionException
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getPriority()
- */
- public byte getPriority()
+ public Boolean getBooleanProperty(String key) throws PropertyConversionException
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getProperties()
- */
- public TypedProperties getProperties()
+ public Byte getByteProperty(SimpleString key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getPropertiesEncodeSize()
- */
- public int getHeadersAndPropertiesEncodeSize()
+ public Byte getByteProperty(String key) throws PropertyConversionException
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getPropertyNames()
- */
- public Set<SimpleString> getPropertyNames()
+ public byte[] getBytesProperty(SimpleString key) throws
PropertyConversionException
{
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getTimestamp()
- */
- public long getTimestamp()
+ public byte[] getBytesProperty(String key) throws PropertyConversionException
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getType()
- */
- public byte getType()
+ public SimpleString getDestination()
{
-
- return 0;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#isDurable()
- */
- public boolean isDurable()
+ public Double getDoubleProperty(SimpleString key) throws
PropertyConversionException
{
-
- return false;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#isExpired()
- */
- public boolean isExpired()
+ public Double getDoubleProperty(String key) throws PropertyConversionException
{
-
- return false;
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#putBooleanProperty(org.hornetq.utils.SimpleString,
boolean)
- */
- public void putBooleanProperty(final SimpleString key, final boolean value)
+ public int getEncodeSize()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#putByteProperty(org.hornetq.utils.SimpleString, byte)
- */
- public void putByteProperty(final SimpleString key, final byte value)
+ public long getExpiration()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#putBytesProperty(org.hornetq.utils.SimpleString, byte[])
- */
- public void putBytesProperty(final SimpleString key, final byte[] value)
+ public Float getFloatProperty(SimpleString key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#putDoubleProperty(org.hornetq.utils.SimpleString,
double)
- */
- public void putDoubleProperty(final SimpleString key, final double value)
+ public Float getFloatProperty(String key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#putFloatProperty(org.hornetq.utils.SimpleString, float)
- */
- public void putFloatProperty(final SimpleString key, final float value)
+ public int getHeadersAndPropertiesEncodeSize()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#putIntProperty(org.hornetq.utils.SimpleString, int)
- */
- public void putIntProperty(final SimpleString key, final int value)
+ public Integer getIntProperty(SimpleString key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#putLongProperty(org.hornetq.utils.SimpleString, long)
- */
- public void putLongProperty(final SimpleString key, final long value)
+ public Integer getIntProperty(String key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#putShortProperty(org.hornetq.utils.SimpleString, short)
- */
- public void putShortProperty(final SimpleString key, final short value)
+ public long getLargeBodySize()
{
-
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#putStringProperty(org.hornetq.utils.SimpleString,
org.hornetq.utils.SimpleString)
- */
- public void putStringProperty(final SimpleString key, final SimpleString value)
+ public Long getLongProperty(SimpleString key) throws PropertyConversionException
{
-
- }
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#getSimpleStringProperty(org.hornetq.utils.SimpleString)
- */
- public SimpleString getSimpleStringProperty(SimpleString key) throws
PropertyConversionException
- {
// TODO Auto-generated method stub
return null;
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getSimpleStringProperty(java.lang.String)
- */
- public SimpleString getSimpleStringProperty(String key) throws
PropertyConversionException
+ public Long getLongProperty(String key) throws PropertyConversionException
{
// TODO Auto-generated method stub
return null;
}
-
- public void putObjectProperty(SimpleString key, Object value)
+
+ public long getMessageID()
{
// TODO Auto-generated method stub
-
+ return 0;
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putObjectProperty(java.lang.String,
java.lang.Object)
- */
- public void putObjectProperty(String key, Object value)
+
+ public Object getObjectProperty(SimpleString key)
{
// TODO Auto-generated method stub
-
+ return null;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#putTypedProperties(org.hornetq.utils.TypedProperties)
- */
- public void putTypedProperties(final TypedProperties properties)
+ public Object getObjectProperty(String key)
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#removeProperty(org.hornetq.utils.SimpleString)
- */
- public Object removeProperty(final SimpleString key)
+ public byte getPriority()
{
-
- return null;
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#setBody(org.hornetq.core.remoting.spi.HornetQBuffer)
- */
- public void setBuffer(final HornetQBuffer body)
+ public TypedProperties getProperties()
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#setDestination(org.hornetq.utils.SimpleString)
- */
- public void setDestination(final SimpleString destination)
+ public Set<SimpleString> getPropertyNames()
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setDurable(boolean)
- */
- public void setDurable(final boolean durable)
+ public Short getShortProperty(SimpleString key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setExpiration(long)
- */
- public void setExpiration(final long expiration)
+ public Short getShortProperty(String key) throws PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setPriority(byte)
- */
- public void setPriority(final byte priority)
+ public SimpleString getSimpleStringProperty(SimpleString key) throws
PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setTimestamp(long)
- */
- public void setTimestamp(final long timestamp)
+ public SimpleString getSimpleStringProperty(String key) throws
PropertyConversionException
{
-
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBodyInputStream()
- */
- public InputStream getBodyInputStream()
+ public String getStringProperty(SimpleString key) throws
PropertyConversionException
{
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#setBodyInputStream(java.io.InputStream)
- */
- public void setBodyInputStream(InputStream stream)
+ public String getStringProperty(String key) throws PropertyConversionException
{
+ // TODO Auto-generated method stub
+ return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getLargeBodySize()
- */
- public long getLargeBodySize()
+ public long getTimestamp()
{
+ // TODO Auto-generated method stub
return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#containsProperty(java.lang.String)
- */
- public boolean containsProperty(String key)
+ public byte getType()
{
-
- return false;
+ // TODO Auto-generated method stub
+ return 0;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getProperty(java.lang.String)
- */
- public Object getObjectProperty(String key)
+ public HornetQBuffer getWholeBuffer()
{
-
+ // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putBooleanProperty(java.lang.String,
boolean)
- */
- public void putBooleanProperty(String key, boolean value)
+ public boolean isBufferWritten()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putByteProperty(java.lang.String, byte)
- */
- public void putByteProperty(String key, byte value)
+ public boolean isDurable()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putBytesProperty(java.lang.String,
byte[])
- */
- public void putBytesProperty(String key, byte[] value)
+ public boolean isEncodedToBuffer()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putDoubleProperty(java.lang.String,
double)
- */
- public void putDoubleProperty(String key, double value)
+ public boolean isExpired()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putFloatProperty(java.lang.String, float)
- */
- public void putFloatProperty(String key, float value)
+ public boolean isLargeMessage()
{
-
+ // TODO Auto-generated method stub
+ return false;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putIntProperty(java.lang.String, int)
- */
- public void putIntProperty(String key, int value)
+ public void putBooleanProperty(SimpleString key, boolean value)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putLongProperty(java.lang.String, long)
- */
- public void putLongProperty(String key, long value)
+ public void putBooleanProperty(String key, boolean value)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putShortProperty(java.lang.String, short)
- */
- public void putShortProperty(String key, short value)
+ public void putByteProperty(SimpleString key, byte value)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#putStringProperty(java.lang.String,
java.lang.String)
- */
- public void putStringProperty(String key, String value)
+ public void putByteProperty(String key, byte value)
{
-
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#removeProperty(java.lang.String)
- */
- public Object removeProperty(String key)
+ public void putBytesProperty(SimpleString key, byte[] value)
{
-
- return null;
+ // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#getStringProperty(org.hornetq.utils.SimpleString)
- */
- public String getStringProperty(SimpleString key)
+ public void putBytesProperty(String key, byte[] value)
{
// TODO Auto-generated method stub
- return null;
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#getBooleanProperty(org.hornetq.utils.SimpleString)
- */
- public Boolean getBooleanProperty(SimpleString key)
+ public void putDoubleProperty(SimpleString key, double value)
{
// TODO Auto-generated method stub
- return false;
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#getByteProperty(org.hornetq.utils.SimpleString)
- */
- public Byte getByteProperty(SimpleString key)
+ public void putDoubleProperty(String key, double value)
{
// TODO Auto-generated method stub
- return 0;
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#getBytesProperty(org.hornetq.utils.SimpleString)
- */
- public byte[] getBytesProperty(SimpleString key) throws
PropertyConversionException
+ public void putFloatProperty(SimpleString key, float value)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#getDoubleProperty(org.hornetq.utils.SimpleString)
- */
- public Double getDoubleProperty(SimpleString key)
+
+ public void putFloatProperty(String key, float value)
{
// TODO Auto-generated method stub
- return 0.0;
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#getFloatProperty(org.hornetq.utils.SimpleString)
- */
- public Float getFloatProperty(SimpleString key)
+ public void putIntProperty(SimpleString key, int value)
{
// TODO Auto-generated method stub
- return 0f;
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#getIntProperty(org.hornetq.utils.SimpleString)
- */
- public Integer getIntProperty(SimpleString key)
+ public void putIntProperty(String key, int value)
{
// TODO Auto-generated method stub
- return 0;
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#getLongProperty(org.hornetq.utils.SimpleString)
- */
- public Long getLongProperty(SimpleString key)
+ public void putLongProperty(SimpleString key, long value)
{
// TODO Auto-generated method stub
- return 0L;
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#getObjectProperty(org.hornetq.utils.SimpleString)
- */
- public Object getObjectProperty(SimpleString key)
+ public void putLongProperty(String key, long value)
{
// TODO Auto-generated method stub
- return null;
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.message.Message#getShortProperty(org.hornetq.utils.SimpleString)
- */
- public Short getShortProperty(SimpleString key)
+ public void putObjectProperty(SimpleString key, Object value) throws
PropertyConversionException
{
// TODO Auto-generated method stub
- return 0;
+
}
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBooleanProperty(java.lang.String)
- */
- public Boolean getBooleanProperty(String key) throws PropertyConversionException
+
+ public void putObjectProperty(String key, Object value) throws
PropertyConversionException
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getByteProperty(java.lang.String)
- */
- public Byte getByteProperty(String key) throws PropertyConversionException
+
+ public void putShortProperty(SimpleString key, short value)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBytesProperty(java.lang.String)
- */
- public byte[] getBytesProperty(String key) throws PropertyConversionException
+
+ public void putShortProperty(String key, short value)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getDoubleProperty(java.lang.String)
- */
- public Double getDoubleProperty(String key) throws PropertyConversionException
+
+ public void putStringProperty(SimpleString key, SimpleString value)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getFloatProperty(java.lang.String)
- */
- public Float getFloatProperty(String key) throws PropertyConversionException
+
+ public void putStringProperty(String key, String value)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getIntProperty(java.lang.String)
- */
- public Integer getIntProperty(String key) throws PropertyConversionException
+
+ public void putTypedProperties(TypedProperties properties)
{
// TODO Auto-generated method stub
- return null;
+
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getLongProperty(java.lang.String)
- */
- public Long getLongProperty(String key) throws PropertyConversionException
+
+ public Object removeProperty(SimpleString key)
{
// TODO Auto-generated method stub
return null;
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getShortProperty(java.lang.String)
- */
- public Short getShortProperty(String key) throws PropertyConversionException
+
+ public Object removeProperty(String key)
{
// TODO Auto-generated method stub
return null;
}
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getStringProperty(java.lang.String)
- */
- public String getStringProperty(String key) throws PropertyConversionException
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see
org.hornetq.core.server.ServerMessage#decrementRefCount(org.hornetq.core.paging.PagingStore,
org.hornetq.core.server.MessageReference)
- */
- public int decrementRefCount(PagingStore pagingStore, MessageReference reference)
throws Exception
+ public void setBuffer(HornetQBuffer buffer)
{
// TODO Auto-generated method stub
- return 0;
+
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.server.ServerMessage#incrementRefCount(org.hornetq.core.paging.PagingStore,
org.hornetq.core.server.MessageReference)
- */
- public int incrementRefCount(PagingStore pagingStore, MessageReference reference)
throws Exception
+ public void setDestination(SimpleString destination)
{
// TODO Auto-generated method stub
- return 0;
+
}
- public PagingStore getPagingStore()
+ public void setDurable(boolean durable)
{
// TODO Auto-generated method stub
- return null;
+
}
- public void setPagingStore(PagingStore store)
+ public void setExpiration(long expiration)
{
// TODO Auto-generated method stub
}
- public boolean page(boolean duplicateDetection) throws Exception
+ public void setPriority(byte priority)
{
// TODO Auto-generated method stub
- return false;
+
}
- public boolean page(long transactionID, boolean duplicateDetection) throws
Exception
+ public void setTimestamp(long timestamp)
{
// TODO Auto-generated method stub
- return false;
+
}
- public boolean storeIsPaging()
+ public Map<String, Object> toMap()
{
// TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.message.Message#getBodyEncoder()
- */
- public BodyEncoder getBodyEncoder()
- {
- // TODO Auto-generated method stub
return null;
}
- public int decrementRefCount(MessageReference reference) throws Exception
+ public void decode(HornetQBuffer buffer)
{
// TODO Auto-generated method stub
- return 0;
+
}
- public int incrementRefCount(MessageReference reference) throws Exception
+ public void encode(HornetQBuffer buffer)
{
// TODO Auto-generated method stub
- return 0;
+
}
+
}
class FakeFilter implements Filter
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/util/ServiceTestBase.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/util/ServiceTestBase.java 2009-11-21
23:29:50 UTC (rev 8366)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/util/ServiceTestBase.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -353,8 +353,8 @@
public String getTextMessage(ClientMessage m)
{
- //m.getBuffer().resetReaderIndex();
- return m.getBuffer().readString();
+ //m.getBodyBuffer().resetReaderIndex();
+ return m.getBodyBuffer().readString();
}
protected ClientMessage createTextMessage(final ClientSession session, final String s,
final boolean durable)
@@ -364,7 +364,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(s);
+ message.getBodyBuffer().writeString(s);
return message;
}
@@ -375,7 +375,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeBytes(b);
+ message.getBodyBuffer().writeBytes(b);
return message;
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java 2009-11-21
23:29:50 UTC (rev 8366)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java 2009-11-22
18:47:45 UTC (rev 8367)
@@ -833,16 +833,11 @@
protected ServerMessage generateMessage(long id)
{
- ServerMessage message = new ServerMessageImpl((byte)0,
- true,
- 0,
- System.currentTimeMillis(),
- (byte)4,
-
HornetQChannelBuffers.dynamicBuffer(1024));
+ ServerMessage message = new ServerMessageImpl();
message.setMessageID(id);
- message.getBuffer().writeString(UUID.randomUUID().toString());
+ message.getBodyBuffer().writeString(UUID.randomUUID().toString());
message.setDestination(new SimpleString("foo"));
@@ -873,7 +868,7 @@
0,
System.currentTimeMillis(),
(byte)1);
- message.getBuffer().writeString(s);
+ message.getBodyBuffer().writeString(s);
return message;
}