Skip to content

Commit 7175eca

Browse files
authored
[fix][artemis] Fix Artemis asynchronous send and acknowledgement configuration (#343)
* [fix][artemis] Fix Artemis confirmation windows size configuration - set to 1MB which is a more sensible default value - see https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/client/SendAcknowledgementHandler.html - configuring confirmation window is required for async message sending with Artemis * [fix][artemis] Fix reporting of failed sends * [fix][artemis] Use async sending and acknowledgements * Reformat with spotless
1 parent d7cc6c3 commit 7175eca

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

driver-artemis/src/main/java/io/openmessaging/benchmark/driver/artemis/ArtemisBenchmarkDriver.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ public void initialize(File configurationFile, StatsLogger statsLogger) throws I
4949
log.info("ActiveMQ Artemis driver configuration: {}", writer.writeValueAsString(config));
5050
try {
5151
ServerLocator serverLocator = ActiveMQClient.createServerLocator(config.brokerAddress);
52-
serverLocator.setConfirmationWindowSize(1000);
52+
// confirmation window size is in bytes, set to 1MB
53+
serverLocator.setConfirmationWindowSize(1024 * 1024);
54+
// use asynchronous sending of messages where SendAcknowledgementHandler reports
55+
// success/failure
56+
serverLocator.setBlockOnDurableSend(false);
57+
serverLocator.setBlockOnNonDurableSend(false);
58+
// use async acknowledgement
59+
serverLocator.setBlockOnAcknowledge(false);
5360

5461
sessionFactory = serverLocator.createSessionFactory();
5562
session = sessionFactory.createSession();

driver-artemis/src/main/java/io/openmessaging/benchmark/driver/artemis/ArtemisBenchmarkProducer.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
import java.util.Optional;
1919
import java.util.concurrent.CompletableFuture;
2020
import org.apache.activemq.artemis.api.core.ActiveMQException;
21+
import org.apache.activemq.artemis.api.core.Message;
2122
import org.apache.activemq.artemis.api.core.client.ClientMessage;
2223
import org.apache.activemq.artemis.api.core.client.ClientProducer;
2324
import org.apache.activemq.artemis.api.core.client.ClientSession;
2425
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
26+
import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
2527

2628
public class ArtemisBenchmarkProducer implements BenchmarkProducer {
2729

@@ -51,8 +53,16 @@ public CompletableFuture<Void> sendAsync(Optional<String> key, byte[] payload) {
5153
try {
5254
producer.send(
5355
msg,
54-
message -> {
55-
future.complete(null);
56+
new SendAcknowledgementHandler() {
57+
@Override
58+
public void sendAcknowledged(Message message) {
59+
future.complete(null);
60+
}
61+
62+
@Override
63+
public void sendFailed(Message message, Exception e) {
64+
future.completeExceptionally(e);
65+
}
5666
});
5767
} catch (ActiveMQException e) {
5868
future.completeExceptionally(e);

0 commit comments

Comments
 (0)