jiazhai closed pull request #2949: default enable cpp client producer batch
URL: https://github.com/apache/pulsar/pull/2949
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/pulsar-client-cpp/lib/ProducerConfigurationImpl.h
b/pulsar-client-cpp/lib/ProducerConfigurationImpl.h
index 6dfaeedf3a..cc5b9b7fe6 100644
--- a/pulsar-client-cpp/lib/ProducerConfigurationImpl.h
+++ b/pulsar-client-cpp/lib/ProducerConfigurationImpl.h
@@ -53,7 +53,7 @@ struct ProducerConfigurationImpl {
routingMode(ProducerConfiguration::UseSinglePartition),
hashingScheme(ProducerConfiguration::BoostHash),
blockIfQueueFull(false),
- batchingEnabled(false),
+ batchingEnabled(true),
batchingMaxMessages(1000),
batchingMaxAllowedSizeInBytes(128 * 1024), // 128 KB
batchingMaxPublishDelayMs(10), // 10 milli seconds
diff --git a/pulsar-client-cpp/tests/BasicEndToEndTest.cc
b/pulsar-client-cpp/tests/BasicEndToEndTest.cc
index 122a643b85..396eba7298 100644
--- a/pulsar-client-cpp/tests/BasicEndToEndTest.cc
+++ b/pulsar-client-cpp/tests/BasicEndToEndTest.cc
@@ -1080,6 +1080,7 @@ TEST(BasicEndToEndTest, testProduceMessageSize) {
Promise<Result, Producer> producerPromise2;
ProducerConfiguration conf;
conf.setCompressionType(CompressionLZ4);
+ conf.setBatchingEnabled(false);
client.createProducerAsync(topicName, conf,
WaitForCallbackValue<Producer>(producerPromise2));
producerFuture = producerPromise2.getFuture();
result = producerFuture.get(producer2);
@@ -1267,6 +1268,7 @@ TEST(BasicEndToEndTest, testEncryptionFailure) {
{
ProducerConfiguration prodConf;
prodConf.setCryptoKeyReader(keyReader);
+ prodConf.setBatchingEnabled(false);
prodConf.addEncryptionKey("client-non-existing-rsa.pem");
Promise<Result, Producer> producerPromise;
@@ -1282,6 +1284,7 @@ TEST(BasicEndToEndTest, testEncryptionFailure) {
{
ProducerConfiguration prodConf;
prodConf.setCryptoKeyReader(keyReader);
+ prodConf.setBatchingEnabled(false);
prodConf.addEncryptionKey("client-rsa.pem");
Promise<Result, Producer> producerPromise;
@@ -2158,4 +2161,4 @@ TEST(BasicEndToEndTest,
testSyncFlushBatchMessagesPartitionedTopic) {
producer.close();
client.shutdown();
-}
\ No newline at end of file
+}
diff --git a/pulsar-client-cpp/tests/ReaderTest.cc
b/pulsar-client-cpp/tests/ReaderTest.cc
index 1f293c9364..fd6cf5d8a5 100644
--- a/pulsar-client-cpp/tests/ReaderTest.cc
+++ b/pulsar-client-cpp/tests/ReaderTest.cc
@@ -363,7 +363,7 @@ TEST(ReaderTest, testReaderReachEndOfTopic) {
client.close();
}
-TEST(ReaderTest, testReaderReachEndOfTopicMessageWithBatches) {
+TEST(ReaderTest, testReaderReachEndOfTopicMessageWithoutBatches) {
Client client(serviceUrl);
std::string topicName =
@@ -371,7 +371,9 @@ TEST(ReaderTest,
testReaderReachEndOfTopicMessageWithBatches) {
// 1. create producer
Producer producer;
- ASSERT_EQ(ResultOk, client.createProducer(topicName, producer));
+ ProducerConfiguration producerConf;
+ producerConf.setBatchingEnabled(false);
+ ASSERT_EQ(ResultOk, client.createProducer(topicName, producerConf,
producer));
// 2. create reader, and expect hasMessageAvailable return false since no
message produced.
ReaderConfiguration readerConf;
@@ -415,4 +417,4 @@ TEST(ReaderTest,
testReaderReachEndOfTopicMessageWithBatches) {
producer.close();
reader.close();
client.close();
-}
\ No newline at end of file
+}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services