poorbarcode commented on code in PR #20695:
URL: https://github.com/apache/pulsar/pull/20695#discussion_r1251407429
##########
pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerTest.java:
##########
@@ -340,6 +353,58 @@ public Object[][] codecProvider() {
return new Object[][] { { 0 }, { 1000 } };
}
+ @Test(dataProvider = "subscriptionTypes")
+ public void testConsumerReconnectTwice(SubscriptionType subscriptionType)
throws Exception {
+ final String topicName =
BrokerTestUtil.newUniqueName("persistent://my-property/my-ns/tp_");
+ final String subscriptionName = "subscription1";
+ admin.topics().createNonPartitionedTopic(topicName);
+ admin.topics().createSubscription(topicName, subscriptionName,
MessageId.earliest);
+ // Create producer and consumer.
+ ConsumerImpl<String> consumer = (ConsumerImpl<String>)
pulsarClient.newConsumer(Schema.STRING)
+ .subscriptionType(subscriptionType)
+
.receiverQueueSize(1000).topic(topicName).subscriptionName(subscriptionName).subscribe();
+ Producer<String> producer =
pulsarClient.newProducer(Schema.STRING).enableBatching(false)
+ .topic(topicName).create();
+ int sendMessageCount = 10;
+ for (int i = 0; i < sendMessageCount; i++){
+ producer.send("msg- " + i);
+ }
+ Awaitility.await().untilAsserted(() -> {
+ assertEquals(consumer.numMessagesInQueue(), sendMessageCount);
+ });
+ printConsumerStats(topicName, subscriptionName);
+
+ // Do the second subscribe.
+ consumer.connectionOpened(consumer.getClientCnx());
Review Comment:
> It's still not clear in which case ConsumerImpl#connectionOpened will be
called when the state is Ready. It does not make sense here that you called it
manually.
Yes, it is only a simple test to prevent someone to change 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]