Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARTEMIS-4588 30 second pause for large msgs + federation #4815

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public class LargeMessageControllerImpl implements LargeMessageController {

private long packetLastPosition = -1;

private long bytesTaken = 0;

private OutputStream outStream;

// There's no need to wait a synchronization
Expand Down Expand Up @@ -315,7 +317,9 @@ public synchronized boolean waitCompletion(final long timeWait) throws ActiveMQE

@Override
public LargeData take() throws InterruptedException {
return largeMessageData.take();
LargeData largeData = largeMessageData.take();
bytesTaken += largeData.getChunk().length;
return largeData;
}

/**
Expand Down Expand Up @@ -1146,6 +1150,10 @@ private void popPacket() {
}

private void checkForPacket(final long index) {
if (totalSize == bytesTaken) {
return;
}

if (outStream != null) {
throw new IllegalAccessError("Can't read the messageBody after setting outputStream");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ private void testFederatedQueueRemoteConsume(final String queueName) throws Exce

@Test
public void testWithLargeMessage() throws Exception {
internalTestWithLargeMessages(1);
}

@Test
public void testWithMultipleLargeMessages() throws Exception {
internalTestWithLargeMessages(5);
}

private void internalTestWithLargeMessages(int messageNumber) throws Exception {
String queueName = getName();

FederationConfiguration federationConfiguration = FederatedTestUtil.createQueueUpstreamFederationConfiguration("server1", queueName);
Expand All @@ -319,14 +328,18 @@ public void testWithLargeMessage() throws Exception {
Session session1 = connection1.createSession();
Queue queue1 = session1.createQueue(queueName);
MessageProducer producer = session1.createProducer(queue1);
producer.send(session1.createTextMessage(payload));
for (int i = 0; i < messageNumber; i++) {
producer.send(session1.createTextMessage(payload));
}

connection0.start();
Session session0 = connection0.createSession();
Queue queue0 = session0.createQueue(queueName);
MessageConsumer consumer0 = session0.createConsumer(queue0);

assertNotNull(consumer0.receive(60000));
for (int i = 0; i < messageNumber; i++) {
assertNotNull(consumer0.receive(1000));
}
}
}

Expand Down Expand Up @@ -704,5 +717,4 @@ public org.apache.activemq.artemis.api.core.Message transform(org.apache.activem
return message;
}
}

}
Loading