aloyszhang commented on a change in pull request #8387:
URL: https://github.com/apache/pulsar/pull/8387#discussion_r513648491
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerTest.java
##########
@@ -3037,6 +3037,74 @@ public void testConsumerSubscriptionInitialize() throws
Exception {
log.info("-- Exiting {} test --", methodName);
}
+ @Test
+ public void testMultiTopicsConsumerImplPause() throws Exception {
+ log.info("-- Starting {} test --", methodName);
+ String topicName = "persistent://my-property/my-ns/partition-topic";
+
+ admin.topics().createPartitionedTopic(topicName, 1);
+
+
+ Producer<byte[]> producer = pulsarClient.newProducer()
+ .topic(topicName)
+ .enableBatching(false)
+ .autoUpdatePartitionsInterval(2 ,TimeUnit.SECONDS)
+ .create();
+
+ // 1. produce 5 messages
+ for (int i = 0; i < 5; i++) {
+ final String message = "my-message-" + i;
+ producer.send(message.getBytes(UTF_8));
+ }
+
+ Consumer<byte[]> consumer = pulsarClient.newConsumer().topic(topicName)
+
.subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
+ .receiverQueueSize(1)
+ .autoUpdatePartitionsInterval(2 ,TimeUnit.SECONDS)
+ .subscriptionName("test-multi-topic-consumer").subscribe();
+
+ int counter = 0;
+ Message<byte[]> consumedMessage = consumer.receive(3,
TimeUnit.SECONDS);
+ while(consumedMessage != null) {
+ assertEquals(consumedMessage.getData(), ("my-message-" + counter++
).getBytes());
+ consumedMessage = consumer.receive(3, TimeUnit.SECONDS);
+ }
+ assertEquals(counter, 5);
+
+ // 2. pause multi-topic consumer
+ consumer.pause();
+
+ // 3. update partition
+ admin.topics().updatePartitionedTopic(topicName, 3);
+
+ // 4. wait for client to update partitions
+ Thread.sleep(5000);
Review comment:
will optimize
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]