ARTEMIS-1444 Fixing byte buffer conversion

I'm also using a lower size on message, to speed up the new test.

(100M may be a lot on some CIs)
This commit is contained in:
Clebert Suconic 2017-10-09 12:49:48 -04:00
parent 988c91557d
commit 1d5fe2862a
2 changed files with 6 additions and 3 deletions

View File

@ -32,6 +32,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import org.apache.activemq.artemis.Closeable; import org.apache.activemq.artemis.Closeable;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException; import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException;
import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException; import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
@ -1315,7 +1316,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
ICoreMessage coreMessage = message.toCore(); ICoreMessage coreMessage = message.toCore();
LargeServerMessage lsm = getStorageManager().createLargeMessage(storageManager.generateID(), coreMessage); LargeServerMessage lsm = getStorageManager().createLargeMessage(storageManager.generateID(), coreMessage);
byte[] body = coreMessage.getReadOnlyBodyBuffer().toByteBuffer().array(); ActiveMQBuffer buffer = coreMessage.getReadOnlyBodyBuffer();
byte[] body = new byte[buffer.readableBytes()];
buffer.readBytes(body);
lsm.addBytes(body); lsm.addBytes(body);
lsm.releaseResources(); lsm.releaseResources();
lsm.putLongProperty(Message.HDR_LARGE_BODY_SIZE, body.length); lsm.putLongProperty(Message.HDR_LARGE_BODY_SIZE, body.length);

View File

@ -52,8 +52,8 @@ public class OpenWireLargeMessageTest extends BasicOpenWireTest {
MessageProducer producer = session.createProducer(queue); MessageProducer producer = session.createProducer(queue);
producer.setDeliveryMode(DeliveryMode.PERSISTENT); producer.setDeliveryMode(DeliveryMode.PERSISTENT);
// Create 100Mb Message // Create 1MB Message
int size = 1024 * 1024 * 10; int size = 1024 * 1024;
byte[] bytes = new byte[size]; byte[] bytes = new byte[size];
BytesMessage message = session.createBytesMessage(); BytesMessage message = session.createBytesMessage();
message.writeBytes(bytes); message.writeBytes(bytes);