You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ba...@apache.org on 2025/05/26 10:02:47 UTC
(pulsar-client-node) branch branch-1.13 updated (35ae9ec -> 0544beb)
This is an automated email from the ASF dual-hosted git repository.
baodi pushed a change to branch branch-1.13
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git
from 35ae9ec Release v1.13.1
new 13cd3ac Upgrade libraries with security vulnerabilities (#414)
new 10c9218 Fix: Enclose variables in double quotes (#413)
new 7d15fdb Support set connectionTimeout param (#410)
new 295dfec call correct function to set subscription role prefix (#416)
new 0544beb Support Key-based batcher for producer (#418)
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
index.d.ts | 7 +
package-lock.json | 347 +++++++++++++--------------------------
package.json | 1 +
pkg/linux/download-cpp-client.sh | 10 +-
src/Client.cc | 13 ++
src/Message.cc | 11 +-
src/Message.h | 1 +
src/ProducerConfig.cc | 16 ++
src/ReaderConfig.cc | 3 +-
tests/end_to_end.test.js | 115 +++++++++++++
10 files changed, 282 insertions(+), 242 deletions(-)
(pulsar-client-node) 04/05: call correct function to set subscription role prefix (#416)
Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
baodi pushed a commit to branch branch-1.13
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git
commit 295dfecdeace19edce424e172fbdf6ea18e91ca8
Author: Evan Savage <sa...@pm.me>
AuthorDate: Thu May 22 10:24:51 2025 +0200
call correct function to set subscription role prefix (#416)
(cherry picked from commit 8b2cfd364a1765136efc302423ed70b31e0b068b)
---
src/ReaderConfig.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/ReaderConfig.cc b/src/ReaderConfig.cc
index 1e56063..539da07 100644
--- a/src/ReaderConfig.cc
+++ b/src/ReaderConfig.cc
@@ -72,7 +72,8 @@ ReaderConfig::ReaderConfig(const Napi::Object &readerConfig, pulsar_reader_liste
std::string subscriptionRolePrefix =
readerConfig.Get(CFG_SUBSCRIPTION_ROLE_PREFIX).ToString().Utf8Value();
if (!subscriptionRolePrefix.empty())
- pulsar_reader_configuration_set_reader_name(this->cReaderConfig.get(), subscriptionRolePrefix.c_str());
+ pulsar_reader_configuration_set_subscription_role_prefix(this->cReaderConfig.get(),
+ subscriptionRolePrefix.c_str());
}
if (readerConfig.Has(CFG_READ_COMPACTED) && readerConfig.Get(CFG_READ_COMPACTED).IsBoolean()) {
(pulsar-client-node) 03/05: Support set connectionTimeout param (#410)
Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
baodi pushed a commit to branch branch-1.13
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git
commit 7d15fdbdd5830d576e40937655d8a76791f11a7b
Author: Baodi Shi <ba...@apache.org>
AuthorDate: Wed May 14 16:41:50 2025 +0800
Support set connectionTimeout param (#410)
(cherry picked from commit f25b90d0a5c0e46ca3338924d53b494ed9926c51)
---
index.d.ts | 1 +
src/Client.cc | 13 +++++++++++++
tests/end_to_end.test.js | 1 +
3 files changed, 15 insertions(+)
diff --git a/index.d.ts b/index.d.ts
index 804aa64..69837f9 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -33,6 +33,7 @@ export interface ClientConfig {
listenerName?: string;
log?: (level: LogLevel, file: string, line: number, message: string) => void;
logLevel?: LogLevel;
+ connectionTimeoutMs?: number;
}
export class Client {
diff --git a/src/Client.cc b/src/Client.cc
index a9df576..b204fa9 100644
--- a/src/Client.cc
+++ b/src/Client.cc
@@ -26,6 +26,7 @@
#include <pulsar/c/client.h>
#include <pulsar/c/client_configuration.h>
#include <pulsar/c/result.h>
+#include "pulsar/ClientConfiguration.h"
static const std::string CFG_SERVICE_URL = "serviceUrl";
static const std::string CFG_AUTH = "authentication";
@@ -42,9 +43,14 @@ static const std::string CFG_STATS_INTERVAL = "statsIntervalInSeconds";
static const std::string CFG_LOG = "log";
static const std::string CFG_LOG_LEVEL = "logLevel";
static const std::string CFG_LISTENER_NAME = "listenerName";
+static const std::string CFG_CONNECTION_TIMEOUT = "connectionTimeoutMs";
LogCallback *Client::logCallback = nullptr;
+struct _pulsar_client_configuration {
+ pulsar::ClientConfiguration conf;
+};
+
void Client::SetLogHandler(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
@@ -157,6 +163,13 @@ Client::Client(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Client>(info)
}
}
+ if (clientConfig.Has(CFG_CONNECTION_TIMEOUT) && clientConfig.Get(CFG_CONNECTION_TIMEOUT).IsNumber()) {
+ int32_t connectionTimeoutMs = clientConfig.Get(CFG_CONNECTION_TIMEOUT).ToNumber().Int32Value();
+ if (connectionTimeoutMs > 0) {
+ cClientConfig.get()->conf.setConnectionTimeout(connectionTimeoutMs);
+ }
+ }
+
if (clientConfig.Has(CFG_LISTENER_THREADS) && clientConfig.Get(CFG_LISTENER_THREADS).IsNumber()) {
int32_t messageListenerThreads = clientConfig.Get(CFG_LISTENER_THREADS).ToNumber().Int32Value();
if (messageListenerThreads > 0) {
diff --git a/tests/end_to_end.test.js b/tests/end_to_end.test.js
index dbdf8bd..304683d 100644
--- a/tests/end_to_end.test.js
+++ b/tests/end_to_end.test.js
@@ -32,6 +32,7 @@ const Pulsar = require('../index');
serviceUrl,
tlsTrustCertsFilePath: `${__dirname}/certificate/server.crt`,
operationTimeoutSeconds: 30,
+ connectionTimeoutMs: 20000,
listenerName,
});
(pulsar-client-node) 02/05: Fix: Enclose variables in double quotes (#413)
Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
baodi pushed a commit to branch branch-1.13
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git
commit 10c9218811b17fd1c07b2988bcbbf61c318289a3
Author: hrsakai <hs...@lycorp.co.jp>
AuthorDate: Tue May 13 11:27:27 2025 +0900
Fix: Enclose variables in double quotes (#413)
* Enclose variables in double quotes
* Do not set SUDO variable if USER variable is not set
(cherry picked from commit d4251d463a5d5d376e0d199f83d81aae440c2782)
---
pkg/linux/download-cpp-client.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pkg/linux/download-cpp-client.sh b/pkg/linux/download-cpp-client.sh
index 3c1ddcf..634f4e4 100755
--- a/pkg/linux/download-cpp-client.sh
+++ b/pkg/linux/download-cpp-client.sh
@@ -23,14 +23,14 @@ set -e -x
ROOT_DIR=`cd $(dirname $0) && cd ../../ && pwd`
source $ROOT_DIR/pulsar-client-cpp.txt
-if [ $USER != "root" ]; then
+if [ "$USER" != "root" -a "$USER" != "" ]; then
SUDO="sudo"
fi
# Get the flavor of Linux
export $(cat /etc/*-release | grep "^ID=")
UNAME_ARCH=$(uname -m)
-if [ $UNAME_ARCH == 'aarch64' ]; then
+if [ "$UNAME_ARCH" == 'aarch64' ]; then
PLATFORM=arm64
else
PLATFORM=x86_64
@@ -42,18 +42,18 @@ rm -rf $ROOT_DIR/pkg/linux/tmp
mkdir $ROOT_DIR/pkg/linux/tmp
cd $ROOT_DIR/pkg/linux/tmp
-if [ $ID == 'ubuntu' -o $ID == 'debian' ]; then
+if [ "$ID" == 'ubuntu' -o "$ID" == 'debian' ]; then
curl -L -O ${CPP_CLIENT_BASE_URL}/deb-${PLATFORM}/apache-pulsar-client-dev.deb
$SUDO ar x apache-pulsar-client-dev.deb
$SUDO tar -xvf data.tar.xz
cp -r usr/* $ROOT_DIR/pkg/linux/pulsar-cpp/
-elif [ $ID == 'alpine' ]; then
+elif [ "$ID" == 'alpine' ]; then
curl -L -O ${CPP_CLIENT_BASE_URL}/apk-${PLATFORM}/${UNAME_ARCH}/apache-pulsar-client-dev-${CPP_CLIENT_VERSION}-r0.apk
$SUDO tar -xvf apache-pulsar-client-dev-${CPP_CLIENT_VERSION}-r0.apk
cp -r usr/* $ROOT_DIR/pkg/linux/pulsar-cpp/
-elif [ $ID == '"centos"' -o $ID == '"rocky"' ]; then
+elif [ "$ID" == '"centos"' -o "$ID" == '"rocky"' ]; then
curl -L -O ${CPP_CLIENT_BASE_URL}/rpm-${PLATFORM}/${UNAME_ARCH}/apache-pulsar-client-devel-${CPP_CLIENT_VERSION}-1.${UNAME_ARCH}.rpm
$SUDO rpm -i --prefix=$ROOT_DIR/pkg/linux/pulsar-cpp apache-pulsar-client-devel-${CPP_CLIENT_VERSION}-1.${UNAME_ARCH}.rpm --nodeps --force
(pulsar-client-node) 01/05: Upgrade libraries with security vulnerabilities (#414)
Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
baodi pushed a commit to branch branch-1.13
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git
commit 13cd3ace3e186ad894c9caa2f0024f1c44210b89
Author: hrsakai <hs...@lycorp.co.jp>
AuthorDate: Tue May 13 11:09:47 2025 +0900
Upgrade libraries with security vulnerabilities (#414)
* Upgrade libraries with security vulnerabilities
* Downgrade @definitelytyped/utils to 0.0.188
* Downgrade @definitelytyped/utils to 0.0.168
(cherry picked from commit 41f25751c7b7bf44a12dedf666eaf35925dd733b)
---
package-lock.json | 347 ++++++++++++++++++------------------------------------
package.json | 1 +
2 files changed, 113 insertions(+), 235 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index a5ca22e..88dafca 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -15,6 +15,7 @@
"node-addon-api": "^4.3.0"
},
"devDependencies": {
+ "@definitelytyped/utils": "^0.0.168",
"@seadub/clang-format-lint": "0.0.2",
"@types/node": "^14.14.25",
"clang-format": "^1.4.0",
@@ -276,18 +277,18 @@
}
},
"node_modules/@babel/helper-string-parser": {
- "version": "7.22.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz",
- "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz",
+ "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==",
"dev": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
- "version": "7.22.20",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
- "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz",
+ "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==",
"dev": true,
"engines": {
"node": ">=6.9.0"
@@ -303,14 +304,13 @@
}
},
"node_modules/@babel/helpers": {
- "version": "7.22.6",
- "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.6.tgz",
- "integrity": "sha512-YjDs6y/fVOYFV8hAf1rxd1QvR9wJe1pDBZ2AREKq/SDayfPzgk0PBnVuTCE5X1acEpMMNOVUqoe+OwiZGJ+OaA==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.27.1.tgz",
+ "integrity": "sha512-FCvFTm0sWV8Fxhpp2McP5/W53GPllQ9QeQ7SiqGWjMf/LVG07lFa5+pgK05IRhVwtvafT22KF+ZSnM9I545CvQ==",
"dev": true,
"dependencies": {
- "@babel/template": "^7.22.5",
- "@babel/traverse": "^7.22.6",
- "@babel/types": "^7.22.5"
+ "@babel/template": "^7.27.1",
+ "@babel/types": "^7.27.1"
},
"engines": {
"node": ">=6.9.0"
@@ -402,10 +402,13 @@
}
},
"node_modules/@babel/parser": {
- "version": "7.23.0",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz",
- "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==",
+ "version": "7.27.2",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.2.tgz",
+ "integrity": "sha512-QYLs8299NA7WM/bZAdp+CviYYkVoYXlDW2rzliy3chxd1PQjej7JORuMJDJXJUb9g0TT+B99EwaVLKmX+sPXWw==",
"dev": true,
+ "dependencies": {
+ "@babel/types": "^7.27.1"
+ },
"bin": {
"parser": "bin/babel-parser.js"
},
@@ -576,103 +579,33 @@
}
},
"node_modules/@babel/template": {
- "version": "7.22.15",
- "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz",
- "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==",
+ "version": "7.27.2",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz",
+ "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==",
"dev": true,
"dependencies": {
- "@babel/code-frame": "^7.22.13",
- "@babel/parser": "^7.22.15",
- "@babel/types": "^7.22.15"
+ "@babel/code-frame": "^7.27.1",
+ "@babel/parser": "^7.27.2",
+ "@babel/types": "^7.27.1"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/template/node_modules/@babel/code-frame": {
- "version": "7.22.13",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz",
- "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz",
+ "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==",
"dev": true,
"dependencies": {
- "@babel/highlight": "^7.22.13",
- "chalk": "^2.4.2"
+ "@babel/helper-validator-identifier": "^7.27.1",
+ "js-tokens": "^4.0.0",
+ "picocolors": "^1.1.1"
},
"engines": {
"node": ">=6.9.0"
}
},
- "node_modules/@babel/template/node_modules/ansi-styles": {
- "version": "3.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
- "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
- "dev": true,
- "dependencies": {
- "color-convert": "^1.9.0"
- },
- "engines": {
- "node": ">=4"
- }
- },
- "node_modules/@babel/template/node_modules/chalk": {
- "version": "2.4.2",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
- "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
- "dev": true,
- "dependencies": {
- "ansi-styles": "^3.2.1",
- "escape-string-regexp": "^1.0.5",
- "supports-color": "^5.3.0"
- },
- "engines": {
- "node": ">=4"
- }
- },
- "node_modules/@babel/template/node_modules/color-convert": {
- "version": "1.9.3",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
- "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
- "dev": true,
- "dependencies": {
- "color-name": "1.1.3"
- }
- },
- "node_modules/@babel/template/node_modules/color-name": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
- "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
- "dev": true
- },
- "node_modules/@babel/template/node_modules/escape-string-regexp": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
- "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
- "dev": true,
- "engines": {
- "node": ">=0.8.0"
- }
- },
- "node_modules/@babel/template/node_modules/has-flag": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
- "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
- "dev": true,
- "engines": {
- "node": ">=4"
- }
- },
- "node_modules/@babel/template/node_modules/supports-color": {
- "version": "5.5.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
- "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
- "dev": true,
- "dependencies": {
- "has-flag": "^3.0.0"
- },
- "engines": {
- "node": ">=4"
- }
- },
"node_modules/@babel/traverse": {
"version": "7.23.2",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz",
@@ -788,14 +721,13 @@
}
},
"node_modules/@babel/types": {
- "version": "7.23.0",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz",
- "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.1.tgz",
+ "integrity": "sha512-+EzkxvLNfiUeKMgy/3luqfsCWFRXLb7U6wNQTk60tovuckwB15B191tJWvpp4HjiQWdJkCxO3Wbvc6jlk3Xb2Q==",
"dev": true,
"dependencies": {
- "@babel/helper-string-parser": "^7.22.5",
- "@babel/helper-validator-identifier": "^7.22.20",
- "to-fast-properties": "^2.0.0"
+ "@babel/helper-string-parser": "^7.27.1",
+ "@babel/helper-validator-identifier": "^7.27.1"
},
"engines": {
"node": ">=6.9.0"
@@ -825,12 +757,12 @@
"dev": true
},
"node_modules/@definitelytyped/utils": {
- "version": "0.0.163",
- "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.0.163.tgz",
- "integrity": "sha512-6MX5TxaQbG/j2RkCWbcbLvv+YNipKqY0eQJafDhwC/RprUocpg+uYVNlH8XzdKRWOGJ0pq7SZOsJD4C3A01ZXg==",
+ "version": "0.0.168",
+ "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.0.168.tgz",
+ "integrity": "sha512-glIRQzWty8Jw5uQ0L8GU64Lsd9gXwux9FD62fAwnDWE3u0oJLeI4Kb06ADws8oc5insZFZLakW5Kx336ppimeg==",
"dev": true,
"dependencies": {
- "@definitelytyped/typescript-versions": "^0.0.163",
+ "@definitelytyped/typescript-versions": "^0.0.168",
"@qiwi/npm-registry-client": "^8.9.1",
"@types/node": "^14.14.35",
"charm": "^1.0.2",
@@ -840,6 +772,12 @@
"tar-stream": "^2.1.4"
}
},
+ "node_modules/@definitelytyped/utils/node_modules/@definitelytyped/typescript-versions": {
+ "version": "0.0.168",
+ "resolved": "https://registry.npmjs.org/@definitelytyped/typescript-versions/-/typescript-versions-0.0.168.tgz",
+ "integrity": "sha512-AwTLfI9WsQa/xzevhGBG19IYi4cNqqIZ/GfgHVBDsH0yLbrWGnsmohO1NKBRgR1Mpu6daKqOPbIOYeNA32HXdw==",
+ "dev": true
+ },
"node_modules/@definitelytyped/utils/node_modules/fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
@@ -2750,9 +2688,9 @@
"dev": true
},
"node_modules/cross-spawn": {
- "version": "7.0.3",
- "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
- "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"dev": true,
"dependencies": {
"path-key": "^3.1.0",
@@ -3883,6 +3821,7 @@
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz",
"integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==",
+ "deprecated": "This package is no longer supported.",
"dev": true,
"dependencies": {
"graceful-fs": "^4.1.2",
@@ -3898,6 +3837,7 @@
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
+ "deprecated": "Rimraf versions prior to v4 are no longer supported",
"dev": true,
"dependencies": {
"glob": "^7.1.3"
@@ -6250,12 +6190,12 @@
}
},
"node_modules/micromatch": {
- "version": "4.0.5",
- "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
- "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
+ "version": "4.0.8",
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
+ "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true,
"dependencies": {
- "braces": "^3.0.2",
+ "braces": "^3.0.3",
"picomatch": "^2.3.1"
},
"engines": {
@@ -6804,9 +6744,9 @@
"dev": true
},
"node_modules/picocolors": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
- "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
"dev": true
},
"node_modules/picomatch": {
@@ -7937,15 +7877,6 @@
"integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==",
"dev": true
},
- "node_modules/to-fast-properties": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
- "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==",
- "dev": true,
- "engines": {
- "node": ">=4"
- }
- },
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
@@ -8967,15 +8898,15 @@
}
},
"@babel/helper-string-parser": {
- "version": "7.22.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz",
- "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz",
+ "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==",
"dev": true
},
"@babel/helper-validator-identifier": {
- "version": "7.22.20",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
- "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz",
+ "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==",
"dev": true
},
"@babel/helper-validator-option": {
@@ -8985,14 +8916,13 @@
"dev": true
},
"@babel/helpers": {
- "version": "7.22.6",
- "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.6.tgz",
- "integrity": "sha512-YjDs6y/fVOYFV8hAf1rxd1QvR9wJe1pDBZ2AREKq/SDayfPzgk0PBnVuTCE5X1acEpMMNOVUqoe+OwiZGJ+OaA==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.27.1.tgz",
+ "integrity": "sha512-FCvFTm0sWV8Fxhpp2McP5/W53GPllQ9QeQ7SiqGWjMf/LVG07lFa5+pgK05IRhVwtvafT22KF+ZSnM9I545CvQ==",
"dev": true,
"requires": {
- "@babel/template": "^7.22.5",
- "@babel/traverse": "^7.22.6",
- "@babel/types": "^7.22.5"
+ "@babel/template": "^7.27.1",
+ "@babel/types": "^7.27.1"
}
},
"@babel/highlight": {
@@ -9065,10 +8995,13 @@
}
},
"@babel/parser": {
- "version": "7.23.0",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz",
- "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==",
- "dev": true
+ "version": "7.27.2",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.2.tgz",
+ "integrity": "sha512-QYLs8299NA7WM/bZAdp+CviYYkVoYXlDW2rzliy3chxd1PQjej7JORuMJDJXJUb9g0TT+B99EwaVLKmX+sPXWw==",
+ "dev": true,
+ "requires": {
+ "@babel/types": "^7.27.1"
+ }
},
"@babel/plugin-syntax-async-generators": {
"version": "7.8.4",
@@ -9188,80 +9121,25 @@
}
},
"@babel/template": {
- "version": "7.22.15",
- "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz",
- "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==",
+ "version": "7.27.2",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz",
+ "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==",
"dev": true,
"requires": {
- "@babel/code-frame": "^7.22.13",
- "@babel/parser": "^7.22.15",
- "@babel/types": "^7.22.15"
+ "@babel/code-frame": "^7.27.1",
+ "@babel/parser": "^7.27.2",
+ "@babel/types": "^7.27.1"
},
"dependencies": {
"@babel/code-frame": {
- "version": "7.22.13",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz",
- "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==",
- "dev": true,
- "requires": {
- "@babel/highlight": "^7.22.13",
- "chalk": "^2.4.2"
- }
- },
- "ansi-styles": {
- "version": "3.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
- "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
- "dev": true,
- "requires": {
- "color-convert": "^1.9.0"
- }
- },
- "chalk": {
- "version": "2.4.2",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
- "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
- "dev": true,
- "requires": {
- "ansi-styles": "^3.2.1",
- "escape-string-regexp": "^1.0.5",
- "supports-color": "^5.3.0"
- }
- },
- "color-convert": {
- "version": "1.9.3",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
- "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz",
+ "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==",
"dev": true,
"requires": {
- "color-name": "1.1.3"
- }
- },
- "color-name": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
- "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
- "dev": true
- },
- "escape-string-regexp": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
- "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
- "dev": true
- },
- "has-flag": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
- "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
- "dev": true
- },
- "supports-color": {
- "version": "5.5.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
- "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
- "dev": true,
- "requires": {
- "has-flag": "^3.0.0"
+ "@babel/helper-validator-identifier": "^7.27.1",
+ "js-tokens": "^4.0.0",
+ "picocolors": "^1.1.1"
}
}
}
@@ -9359,14 +9237,13 @@
}
},
"@babel/types": {
- "version": "7.23.0",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz",
- "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.1.tgz",
+ "integrity": "sha512-+EzkxvLNfiUeKMgy/3luqfsCWFRXLb7U6wNQTk60tovuckwB15B191tJWvpp4HjiQWdJkCxO3Wbvc6jlk3Xb2Q==",
"dev": true,
"requires": {
- "@babel/helper-string-parser": "^7.22.5",
- "@babel/helper-validator-identifier": "^7.22.20",
- "to-fast-properties": "^2.0.0"
+ "@babel/helper-string-parser": "^7.27.1",
+ "@babel/helper-validator-identifier": "^7.27.1"
}
},
"@bcoe/v8-coverage": {
@@ -9393,12 +9270,12 @@
"dev": true
},
"@definitelytyped/utils": {
- "version": "0.0.163",
- "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.0.163.tgz",
- "integrity": "sha512-6MX5TxaQbG/j2RkCWbcbLvv+YNipKqY0eQJafDhwC/RprUocpg+uYVNlH8XzdKRWOGJ0pq7SZOsJD4C3A01ZXg==",
+ "version": "0.0.168",
+ "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.0.168.tgz",
+ "integrity": "sha512-glIRQzWty8Jw5uQ0L8GU64Lsd9gXwux9FD62fAwnDWE3u0oJLeI4Kb06ADws8oc5insZFZLakW5Kx336ppimeg==",
"dev": true,
"requires": {
- "@definitelytyped/typescript-versions": "^0.0.163",
+ "@definitelytyped/typescript-versions": "^0.0.168",
"@qiwi/npm-registry-client": "^8.9.1",
"@types/node": "^14.14.35",
"charm": "^1.0.2",
@@ -9408,6 +9285,12 @@
"tar-stream": "^2.1.4"
},
"dependencies": {
+ "@definitelytyped/typescript-versions": {
+ "version": "0.0.168",
+ "resolved": "https://registry.npmjs.org/@definitelytyped/typescript-versions/-/typescript-versions-0.0.168.tgz",
+ "integrity": "sha512-AwTLfI9WsQa/xzevhGBG19IYi4cNqqIZ/GfgHVBDsH0yLbrWGnsmohO1NKBRgR1Mpu6daKqOPbIOYeNA32HXdw==",
+ "dev": true
+ },
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
@@ -10904,9 +10787,9 @@
"dev": true
},
"cross-spawn": {
- "version": "7.0.3",
- "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
- "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"dev": true,
"requires": {
"path-key": "^3.1.0",
@@ -13590,12 +13473,12 @@
"dev": true
},
"micromatch": {
- "version": "4.0.5",
- "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
- "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
+ "version": "4.0.8",
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
+ "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true,
"requires": {
- "braces": "^3.0.2",
+ "braces": "^3.0.3",
"picomatch": "^2.3.1"
}
},
@@ -14016,9 +13899,9 @@
"dev": true
},
"picocolors": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
- "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
"dev": true
},
"picomatch": {
@@ -14880,12 +14763,6 @@
"integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==",
"dev": true
},
- "to-fast-properties": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
- "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==",
- "dev": true
- },
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
diff --git a/package.json b/package.json
index 8189aaa..0e06219 100644
--- a/package.json
+++ b/package.json
@@ -35,6 +35,7 @@
"node": ">=12.3.0"
},
"devDependencies": {
+ "@definitelytyped/utils": "^0.0.168",
"@seadub/clang-format-lint": "0.0.2",
"@types/node": "^14.14.25",
"clang-format": "^1.4.0",
(pulsar-client-node) 05/05: Support Key-based batcher for producer (#418)
Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
baodi pushed a commit to branch branch-1.13
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git
commit 0544beb0408c21b30da46fe5fab213fa2f56e173
Author: Baodi Shi <ba...@apache.org>
AuthorDate: Mon May 26 17:52:34 2025 +0800
Support Key-based batcher for producer (#418)
(cherry picked from commit d3174fa829bce76ff436996a152b4b21f51b82d1)
---
index.d.ts | 6 +++
src/Message.cc | 11 ++++-
src/Message.h | 1 +
src/ProducerConfig.cc | 16 +++++++
tests/end_to_end.test.js | 114 +++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 147 insertions(+), 1 deletion(-)
diff --git a/index.d.ts b/index.d.ts
index 69837f9..5097cbc 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -67,6 +67,7 @@ export interface ProducerConfig {
chunkingEnabled?: boolean;
schema?: SchemaInfo;
accessMode?: ProducerAccessMode;
+ batchingType?: ProducerBatchType;
}
export class Producer {
@@ -163,6 +164,7 @@ export class Message {
getEventTimestamp(): number;
getRedeliveryCount(): number;
getPartitionKey(): string;
+ getOrderingKey(): string;
}
export class MessageId {
@@ -271,6 +273,10 @@ export type CompressionType =
'ZSTD' |
'SNAPPY';
+export type ProducerBatchType =
+ 'DefaultBatching' |
+ 'KeyBasedBatching';
+
export type ProducerCryptoFailureAction =
'FAIL' |
'SEND';
diff --git a/src/Message.cc b/src/Message.cc
index 06be544..184b8e7 100644
--- a/src/Message.cc
+++ b/src/Message.cc
@@ -45,7 +45,8 @@ Napi::Object Message::Init(Napi::Env env, Napi::Object exports) {
InstanceMethod("getPublishTimestamp", &Message::GetPublishTimestamp),
InstanceMethod("getEventTimestamp", &Message::GetEventTimestamp),
InstanceMethod("getRedeliveryCount", &Message::GetRedeliveryCount),
- InstanceMethod("getPartitionKey", &Message::GetPartitionKey)});
+ InstanceMethod("getPartitionKey", &Message::GetPartitionKey),
+ InstanceMethod("getOrderingKey", &Message::GetOrderingKey)});
constructor = Napi::Persistent(func);
constructor.SuppressDestruct();
@@ -138,6 +139,14 @@ Napi::Value Message::GetPartitionKey(const Napi::CallbackInfo &info) {
return Napi::String::New(env, pulsar_message_get_partitionKey(this->cMessage.get()));
}
+Napi::Value Message::GetOrderingKey(const Napi::CallbackInfo &info) {
+ Napi::Env env = info.Env();
+ if (!ValidateCMessage(env)) {
+ return env.Null();
+ }
+ return Napi::String::New(env, pulsar_message_get_orderingKey(this->cMessage.get()));
+}
+
bool Message::ValidateCMessage(Napi::Env env) {
if (this->cMessage.get()) {
return true;
diff --git a/src/Message.h b/src/Message.h
index 42d02c1..6097f1c 100644
--- a/src/Message.h
+++ b/src/Message.h
@@ -44,6 +44,7 @@ class Message : public Napi::ObjectWrap<Message> {
Napi::Value GetPublishTimestamp(const Napi::CallbackInfo &info);
Napi::Value GetEventTimestamp(const Napi::CallbackInfo &info);
Napi::Value GetPartitionKey(const Napi::CallbackInfo &info);
+ Napi::Value GetOrderingKey(const Napi::CallbackInfo &info);
Napi::Value GetRedeliveryCount(const Napi::CallbackInfo &info);
bool ValidateCMessage(Napi::Env env);
diff --git a/src/ProducerConfig.cc b/src/ProducerConfig.cc
index 120eebf..2c704bf 100644
--- a/src/ProducerConfig.cc
+++ b/src/ProducerConfig.cc
@@ -19,6 +19,7 @@
#include "SchemaInfo.h"
#include "ProducerConfig.h"
#include <map>
+#include "pulsar/ProducerConfiguration.h"
static const std::string CFG_TOPIC = "topic";
static const std::string CFG_PRODUCER_NAME = "producerName";
@@ -40,6 +41,11 @@ static const std::string CFG_ENCRYPTION_KEY = "encryptionKey";
static const std::string CFG_CRYPTO_FAILURE_ACTION = "cryptoFailureAction";
static const std::string CFG_CHUNK_ENABLED = "chunkingEnabled";
static const std::string CFG_ACCESS_MODE = "accessMode";
+static const std::string CFG_BATCHING_TYPE = "batchingType";
+
+struct _pulsar_producer_configuration {
+ pulsar::ProducerConfiguration conf;
+};
static const std::map<std::string, pulsar_partitions_routing_mode> MESSAGE_ROUTING_MODE = {
{"UseSinglePartition", pulsar_UseSinglePartition},
@@ -71,6 +77,11 @@ static std::map<std::string, pulsar_producer_access_mode> PRODUCER_ACCESS_MODE =
{"ExclusiveWithFencing", pulsar_ProducerAccessModeExclusiveWithFencing},
};
+static std::map<std::string, pulsar::ProducerConfiguration::BatchingType> PRODUCER_BATCHING_TYPE = {
+ {"DefaultBatching", pulsar::ProducerConfiguration::DefaultBatching},
+ {"KeyBasedBatching", pulsar::ProducerConfiguration::KeyBasedBatching},
+};
+
ProducerConfig::ProducerConfig(const Napi::Object& producerConfig) : topic("") {
this->cProducerConfig = std::shared_ptr<pulsar_producer_configuration_t>(
pulsar_producer_configuration_create(), pulsar_producer_configuration_free);
@@ -208,6 +219,11 @@ ProducerConfig::ProducerConfig(const Napi::Object& producerConfig) : topic("") {
pulsar_producer_configuration_set_access_mode(this->cProducerConfig.get(),
PRODUCER_ACCESS_MODE.at(accessMode));
}
+
+ std::string batchingType = producerConfig.Get(CFG_BATCHING_TYPE).ToString().Utf8Value();
+ if (PRODUCER_BATCHING_TYPE.count(batchingType)) {
+ this->cProducerConfig.get()->conf.setBatchingType(PRODUCER_BATCHING_TYPE.at(batchingType));
+ }
}
ProducerConfig::~ProducerConfig() {}
diff --git a/tests/end_to_end.test.js b/tests/end_to_end.test.js
index 304683d..ce3693f 100644
--- a/tests/end_to_end.test.js
+++ b/tests/end_to_end.test.js
@@ -1330,4 +1330,118 @@ const Pulsar = require('../index');
await client.close();
});
});
+ describe('KeyBasedBatchingTest', () => {
+ let client;
+ let producer;
+ let consumer;
+ let topicName;
+
+ beforeAll(async () => {
+ client = new Pulsar.Client({
+ serviceUrl: 'pulsar://localhost:6650',
+ });
+ });
+
+ afterAll(async () => {
+ await client.close();
+ });
+
+ beforeEach(async () => {
+ topicName = `KeyBasedBatchingTest-${Date.now()}`;
+ });
+
+ afterEach(async () => {
+ if (producer) await producer.close();
+ if (consumer) await consumer.close();
+ });
+
+ const initProducer = async (maxMessages) => {
+ producer = await client.createProducer({
+ topic: topicName,
+ batchingEnabled: true,
+ batchingMaxMessages: maxMessages,
+ batchingType: 'KeyBasedBatching',
+ batchingMaxPublishDelayMs: 3600 * 1000,
+ });
+ };
+
+ const initConsumer = async () => {
+ consumer = await client.subscribe({
+ topic: topicName,
+ subscription: 'SubscriptionName',
+ subscriptionType: 'Exclusive',
+ });
+ };
+
+ const receiveAndAck = async () => {
+ const msg = await consumer.receive();
+ await consumer.acknowledge(msg);
+ return msg;
+ };
+
+ test('testSequenceId', async () => {
+ await initProducer(6);
+ await initConsumer();
+
+ // 0. Send 6 messages, use different keys and order
+ producer.send({ data: Buffer.from('0'), partitionKey: 'A' });
+ producer.send({ data: Buffer.from('1'), partitionKey: 'B' });
+ producer.send({ data: Buffer.from('2'), partitionKey: 'C' });
+ producer.send({ data: Buffer.from('3'), partitionKey: 'B' });
+ producer.send({ data: Buffer.from('4'), partitionKey: 'C' });
+ producer.send({ data: Buffer.from('5'), partitionKey: 'A' });
+ await producer.flush();
+
+ // 1. Receive all messages
+ const received = [];
+ for (let i = 0; i < 6; i += 1) {
+ const msg = await receiveAndAck();
+ received.push({
+ key: msg.getPartitionKey().toString(),
+ value: msg.getData().toString(),
+ });
+ }
+
+ // 2. Verify message order (based on key dictionary order)
+ const expected = [
+ { key: 'B', value: '1' },
+ { key: 'B', value: '3' },
+ { key: 'C', value: '2' },
+ { key: 'C', value: '4' },
+ { key: 'A', value: '0' },
+ { key: 'A', value: '5' },
+ ];
+
+ expect(received).toEqual(expected);
+ });
+
+ test('testOrderingKeyPriority', async () => {
+ await initProducer(3);
+ await initConsumer();
+
+ // 1. Send 3 messages to verify orderingKey takes precedence over partitionKey
+ producer.send({
+ data: Buffer.from('0'),
+ orderingKey: 'A',
+ partitionKey: 'B',
+ });
+ producer.send({ data: Buffer.from('2'), orderingKey: 'B' });
+ producer.send({ data: Buffer.from('1'), orderingKey: 'A' });
+ await producer.flush();
+
+ // 2. Receive messages and verify their order and keys
+ const msg1 = await receiveAndAck();
+ expect(msg1.getData().toString()).toBe('2');
+ expect(msg1.getOrderingKey().toString()).toBe('B');
+
+ const msg2 = await receiveAndAck();
+ expect(msg2.getData().toString()).toBe('0');
+ expect(msg2.getOrderingKey()).toBe('A');
+ expect(msg2.getPartitionKey()).toBe('B');
+
+ const msg3 = await receiveAndAck();
+ expect(msg3.getData().toString()).toBe('1');
+ expect(msg3.getOrderingKey().toString()).toBe('A');
+ });
+ });
})();