NO-JIRA Fixing intermittent failure on LargeMessageTest::testSendServerMessageMetrics

When the Database option is used, the packets on the ServerMessage may still be in transit.
We should sync the file on the Database before we can actually send it, otherwise we would get an assertion error on the send method.
This commit is contained in:
Clebert Suconic 2024-05-29 18:48:15 -04:00
parent 5cf206629c
commit 7fbd1b1a51
1 changed files with 5 additions and 1 deletions

View File

@ -2682,7 +2682,7 @@ public class LargeMessageTest extends LargeMessageTestBase {
ClientSession session = sf.createSession(false, false); ClientSession session = sf.createSession(false, false);
LargeServerMessageImpl fileMessage = new LargeServerMessageImpl((JournalStorageManager) server.getStorageManager()); LargeServerMessageImpl fileMessage = new LargeServerMessageImpl(server.getStorageManager());
fileMessage.setMessageID(1005); fileMessage.setMessageID(1005);
@ -2690,6 +2690,10 @@ public class LargeMessageTest extends LargeMessageTestBase {
fileMessage.addBytes(new byte[]{ActiveMQTestBase.getSamplebyte(i)}); fileMessage.addBytes(new byte[]{ActiveMQTestBase.getSamplebyte(i)});
} }
// we need to call sync, especially for JDBC Storage.
// we need to make sure the database has all the packets before a send can be called
fileMessage.getAppendFile().sync();
// The server would be doing this // The server would be doing this
fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, largeMessageSize); fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, largeMessageSize);