merlimat commented on code in PR #25445:
URL: https://github.com/apache/pulsar/pull/25445#discussion_r3017138126
##########
pulsar-broker/src/test/java/org/apache/pulsar/client/api/KeySharedSubscriptionTest.java:
##########
@@ -1775,37 +1766,27 @@ public void
testStickyKeyRangesRestartConsumers(KeySharedImplementationType impl
})
.subscribe();
- Future producerFuture = pulsar.getExecutor().submit(() -> {
- try {
- try (Producer<String> producer =
pulsarClient.newProducer(Schema.STRING)
- .topic(topic)
- .enableBatching(false)
- .create()) {
- for (int i = 0; i < numMessages; i++) {
- String key = "test" + i;
- sentMessages.add(key);
- producer.newMessage()
- .key(key)
- .value("test" + i).
- send();
- Thread.sleep(100);
- }
- }
- } catch (Throwable t) {
- log.error("error", t);
- }
- });
+ @Cleanup
+ Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
+ .topic(topic)
+ .enableBatching(false)
+ .create();
+ for (int i = 0; i < numMessages; i++) {
+ String key = "test" + i;
+ sentMessages.add(key);
+ producer.newMessage()
+ .key(key)
+ .value("test" + i)
+ .sendAsync();
+ }
+ producer.flush();
// wait for some messages to be received by both of the consumers
count1.await(5, TimeUnit.SECONDS);
count2.await(5, TimeUnit.SECONDS);
consumer1.close();
consumer2.close();
- // this sleep is to trigger a race condition that happens
- // when there are some messages that cannot be dispatched while
consuming
- Thread.sleep(3000);
Review Comment:
Yes, it's not ideal.. though let me put the sleep back
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]