/** * Copy constructor * * @param properties * @param copy * @param fileCopy */ private LargeServerMessageImpl(final LargeServerMessageImpl copy, TypedProperties properties, final SequentialFile fileCopy, final long newID) { super(copy, properties); storageManager = copy.storageManager; file = fileCopy; bodySize = copy.bodySize; setMessageID(newID); }
@Override public LargeServerMessage createLargeMessage(final long id, final Message message) throws Exception { readLock(); try { if (isReplicated()) { replicator.largeMessageBegin(id); } LargeServerMessageImpl largeMessage = (LargeServerMessageImpl) createLargeMessage(); largeMessage.copyHeadersAndProperties(message); largeMessage.setMessageID(id); // We do this here to avoid a case where the replication gets a list without this file // to avoid a race largeMessage.validateFile(); if (largeMessage.isDurable()) { // We store a marker on the journal that the large file is pending long pendingRecordID = storePendingLargeMessage(id, LargeServerMessage.NO_PENDING_ID); largeMessage.setPendingRecordID(pendingRecordID); } return largeMessage; } finally { readUnLock(); } }
largeServerMessage.setMessageID(1234); largeServerMessage.addBytes(new byte[0]); assertTrue(open.get());
@Test public void testLargeMessageBodySize() throws Exception { ActiveMQServer server = createServer(true, isNetty(), storeType); server.start(); LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager) server.getStorageManager()); fileMessage.setMessageID(1005); Assert.assertEquals(0, fileMessage.getBodyBufferSize()); for (int i = 0; i < largeMessageSize; i++) { fileMessage.addBytes(new byte[]{ActiveMQTestBase.getSamplebyte(i)}); } Assert.assertEquals(largeMessageSize, fileMessage.getBodyBufferSize()); // The server would be doing this fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, largeMessageSize); fileMessage.releaseResources(); Assert.assertEquals(largeMessageSize, fileMessage.getBodyBufferSize()); }
fileMessage.setMessageID(1005); fileMessage.setDurable(true);
fileMessage.setMessageID(1005); fileMessage.setDurable(true);
LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager) servers[2].getStorageManager()); fileMessage.setMessageID(1005); fileMessage.setDurable(true);
@Test public void testSendServerMessage() throws Exception { ActiveMQServer server = createServer(true, isNetty(), storeType); server.start(); ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator)); ClientSession session = sf.createSession(false, false); LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager) server.getStorageManager()); fileMessage.setMessageID(1005); for (int i = 0; i < largeMessageSize; i++) { fileMessage.addBytes(new byte[]{ActiveMQTestBase.getSamplebyte(i)}); } // The server would be doing this fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, largeMessageSize); 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); Assert.assertNotNull(msg); Assert.assertEquals(msg.getBodySize(), largeMessageSize); for (int i = 0; i < largeMessageSize; i++) { Assert.assertEquals(ActiveMQTestBase.getSamplebyte(i), msg.getBodyBuffer().readByte()); } msg.acknowledge(); session.commit(); }
LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager) server.getStorageManager()); fileMessage.setMessageID(1005);
fileMessage.setMessageID(1005); fileMessage.setDurable(true);
fileMessage.setMessageID(1005);