ARTEMIS-1514 Fix File open on Large Message

This commit is contained in:
Clebert Suconic 2017-11-21 09:27:27 -05:00
parent 3fba3573a5
commit b27ed5de16
2 changed files with 16 additions and 3 deletions

View File

@ -205,6 +205,7 @@ public final class LargeServerMessageImpl extends CoreMessage implements LargeSe
@Override
public ActiveMQBuffer getReadOnlyBodyBuffer() {
try {
validateFile();
file.open();
int fileSize = (int) file.size();
ByteBuffer buffer = this.storageManager.largeMessagesFactory.newBuffer(fileSize);

View File

@ -64,6 +64,11 @@ public class OpenWireLargeMessageTest extends BasicOpenWireTest {
@Test
public void testSendReceiveLargeMessage() throws Exception {
// Create 1MB Message
int size = 1024 * 1024;
byte[] bytes = new byte[size];
try (Connection connection = factory.createConnection()) {
connection.start();
@ -72,14 +77,21 @@ public class OpenWireLargeMessageTest extends BasicOpenWireTest {
MessageProducer producer = session.createProducer(queue);
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
// Create 1MB Message
int size = 1024 * 1024;
byte[] bytes = new byte[size];
bytes[0] = 1;
BytesMessage message = session.createBytesMessage();
message.writeBytes(bytes);
producer.send(message);
}
server.stop();
server.start();
try (Connection connection = factory.createConnection()) {
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(lmAddress.toString());
MessageConsumer consumer = session.createConsumer(queue);
BytesMessage m = (BytesMessage) consumer.receive();