liangyepianzhou commented on code in PR #20948:
URL: https://github.com/apache/pulsar/pull/20948#discussion_r1290039402


##########
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/MessageChunkingSharedTest.java:
##########
@@ -211,6 +213,47 @@ private static String createChunkedMessage(int numChunks) {
         return Schema.STRING.decode(payload);
     }
 
+    @Test
+    public void testDuplicateForChunkMessage() throws Exception {
+        this.conf.setBrokerDeduplicationEnabled(true);
+        restartBroker();
+        String topicName = 
"persistent://my-property/my-ns/testDuplicateForChunkMessage";
+        String producerName = "test-producer";
+        pulsarClient = 
PulsarClient.builder().serviceUrl(pulsar.getBrokerServiceUrl()).build();
+        // consumer
+        Consumer<String> consumer = pulsarClient
+                .newConsumer(Schema.STRING)
+                .subscriptionName("test-sub")
+                .topic(topicName)
+                .subscribe();
+        // producer
+        Producer<String> partProducer = pulsarClient
+                .newProducer(Schema.STRING)
+                .producerName(producerName)
+                .topic(topicName)
+                .enableChunking(true)
+                .enableBatching(false)
+                .create();
+        int messageSize = 6000; // payload size in KB
+        String message = "a".repeat(messageSize * 1000);
+        partProducer.newMessage().value(message).send();
+        Message<String> msg = consumer.receive(5, TimeUnit.SECONDS);
+        assertNotNull(msg);
+        assertEquals(msg.getValue(), message);
+
+        Field msgIdGenerator = 
ProducerImpl.class.getDeclaredField("msgIdGenerator");
+        msgIdGenerator.setAccessible(true);
+        assertEquals(msg.getSequenceId() + 2, 
msgIdGenerator.get(partProducer));
+
+        long sequenceID = (long) msgIdGenerator.get(partProducer);

Review Comment:
   Done.



##########
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/MessageChunkingSharedTest.java:
##########
@@ -211,6 +213,47 @@ private static String createChunkedMessage(int numChunks) {
         return Schema.STRING.decode(payload);
     }
 
+    @Test
+    public void testDuplicateForChunkMessage() throws Exception {
+        this.conf.setBrokerDeduplicationEnabled(true);
+        restartBroker();
+        String topicName = 
"persistent://my-property/my-ns/testDuplicateForChunkMessage";
+        String producerName = "test-producer";
+        pulsarClient = 
PulsarClient.builder().serviceUrl(pulsar.getBrokerServiceUrl()).build();
+        // consumer
+        Consumer<String> consumer = pulsarClient
+                .newConsumer(Schema.STRING)
+                .subscriptionName("test-sub")
+                .topic(topicName)
+                .subscribe();
+        // producer
+        Producer<String> partProducer = pulsarClient
+                .newProducer(Schema.STRING)
+                .producerName(producerName)
+                .topic(topicName)
+                .enableChunking(true)
+                .enableBatching(false)
+                .create();
+        int messageSize = 6000; // payload size in KB
+        String message = "a".repeat(messageSize * 1000);
+        partProducer.newMessage().value(message).send();
+        Message<String> msg = consumer.receive(5, TimeUnit.SECONDS);

Review Comment:
   Done.



-- 
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]

Reply via email to