rocketmq-client-remoting-nodejs 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/README.en.md +428 -0
  2. package/README.md +424 -2
  3. package/dist/client/admin.d.ts +229 -0
  4. package/dist/client/admin.js +2462 -0
  5. package/dist/client/allocate.d.ts +48 -0
  6. package/dist/client/allocate.js +365 -0
  7. package/dist/client/backpressure.d.ts +23 -0
  8. package/dist/client/backpressure.js +95 -0
  9. package/dist/client/consumer.d.ts +294 -0
  10. package/dist/client/consumer.js +3095 -0
  11. package/dist/client/consumer_result.d.ts +129 -0
  12. package/dist/client/consumer_result.js +138 -0
  13. package/dist/client/consumer_stats.d.ts +69 -0
  14. package/dist/client/consumer_stats.js +258 -0
  15. package/dist/client/exception.d.ts +39 -0
  16. package/dist/client/exception.js +36 -0
  17. package/dist/client/hook.d.ts +145 -0
  18. package/dist/client/hook.js +171 -0
  19. package/dist/client/latency.d.ts +61 -0
  20. package/dist/client/latency.js +239 -0
  21. package/dist/client/lite_pull_consumer.d.ts +151 -0
  22. package/dist/client/lite_pull_consumer.js +1096 -0
  23. package/dist/client/mq_client.d.ts +188 -0
  24. package/dist/client/mq_client.js +1678 -0
  25. package/dist/client/mq_client_manager.d.ts +21 -0
  26. package/dist/client/mq_client_manager.js +129 -0
  27. package/dist/client/offset_store.d.ts +45 -0
  28. package/dist/client/offset_store.js +389 -0
  29. package/dist/client/open_tracing_hook.d.ts +52 -0
  30. package/dist/client/open_tracing_hook.js +241 -0
  31. package/dist/client/pop_api.d.ts +28 -0
  32. package/dist/client/pop_api.js +224 -0
  33. package/dist/client/pop_consumer.d.ts +23 -0
  34. package/dist/client/pop_consumer.js +719 -0
  35. package/dist/client/pop_process_queue.d.ts +15 -0
  36. package/dist/client/pop_process_queue.js +51 -0
  37. package/dist/client/process_queue.d.ts +49 -0
  38. package/dist/client/process_queue.js +261 -0
  39. package/dist/client/produce_accumulator.d.ts +75 -0
  40. package/dist/client/produce_accumulator.js +288 -0
  41. package/dist/client/producer.d.ts +231 -0
  42. package/dist/client/producer.js +1774 -0
  43. package/dist/client/pull_api.d.ts +26 -0
  44. package/dist/client/pull_api.js +264 -0
  45. package/dist/client/pull_consumer.d.ts +119 -0
  46. package/dist/client/pull_consumer.js +876 -0
  47. package/dist/client/pull_schedule_service.d.ts +71 -0
  48. package/dist/client/pull_schedule_service.js +424 -0
  49. package/dist/client/request_reply.d.ts +61 -0
  50. package/dist/client/request_reply.js +232 -0
  51. package/dist/client/retry_message.d.ts +2 -0
  52. package/dist/client/retry_message.js +27 -0
  53. package/dist/client/send_result.d.ts +57 -0
  54. package/dist/client/send_result.js +70 -0
  55. package/dist/client/top_addressing.d.ts +20 -0
  56. package/dist/client/top_addressing.js +75 -0
  57. package/dist/client/trace_context.d.ts +61 -0
  58. package/dist/client/trace_context.js +373 -0
  59. package/dist/client/trace_dispatcher.d.ts +31 -0
  60. package/dist/client/trace_dispatcher.js +236 -0
  61. package/dist/client/trace_hook.d.ts +23 -0
  62. package/dist/client/trace_hook.js +228 -0
  63. package/dist/client/traceparent.d.ts +9 -0
  64. package/dist/client/traceparent.js +86 -0
  65. package/dist/common/boundary_type.d.ts +7 -0
  66. package/dist/common/boundary_type.js +16 -0
  67. package/dist/common/compress.d.ts +28 -0
  68. package/dist/common/compress.js +512 -0
  69. package/dist/common/message.d.ts +129 -0
  70. package/dist/common/message.js +214 -0
  71. package/dist/common/messageClientIdSetter.d.ts +7 -0
  72. package/dist/common/messageClientIdSetter.js +48 -0
  73. package/dist/common/messageConst.d.ts +68 -0
  74. package/dist/common/messageConst.js +68 -0
  75. package/dist/common/messageDecoder.d.ts +40 -0
  76. package/dist/common/messageDecoder.js +504 -0
  77. package/dist/common/messageType.d.ts +11 -0
  78. package/dist/common/messageType.js +11 -0
  79. package/dist/common/message_accessor.d.ts +39 -0
  80. package/dist/common/message_accessor.js +135 -0
  81. package/dist/common/mixAll.d.ts +106 -0
  82. package/dist/common/mixAll.js +247 -0
  83. package/dist/common/recall_message_handle.d.ts +25 -0
  84. package/dist/common/recall_message_handle.js +98 -0
  85. package/dist/common/subscriptionData.d.ts +36 -0
  86. package/dist/common/subscriptionData.js +64 -0
  87. package/dist/common/sysflag.d.ts +129 -0
  88. package/dist/common/sysflag.js +96 -0
  89. package/dist/common/topic_config.d.ts +66 -0
  90. package/dist/common/topic_config.js +106 -0
  91. package/dist/common/topic_validator.d.ts +49 -0
  92. package/dist/common/topic_validator.js +115 -0
  93. package/dist/common/utilAll.d.ts +39 -0
  94. package/dist/common/utilAll.js +154 -0
  95. package/dist/common/validators.d.ts +25 -0
  96. package/dist/common/validators.js +80 -0
  97. package/dist/index.d.ts +24 -0
  98. package/dist/index.js +36 -0
  99. package/dist/logging.d.ts +24 -0
  100. package/dist/logging.js +246 -0
  101. package/dist/remoting/acl.d.ts +16 -0
  102. package/dist/remoting/acl.js +39 -0
  103. package/dist/remoting/admin_body.d.ts +257 -0
  104. package/dist/remoting/admin_body.js +669 -0
  105. package/dist/remoting/bodies.d.ts +475 -0
  106. package/dist/remoting/bodies.js +1131 -0
  107. package/dist/remoting/client.d.ts +73 -0
  108. package/dist/remoting/client.js +591 -0
  109. package/dist/remoting/codes.d.ts +296 -0
  110. package/dist/remoting/codes.js +301 -0
  111. package/dist/remoting/exception.d.ts +45 -0
  112. package/dist/remoting/exception.js +58 -0
  113. package/dist/remoting/extra_info.d.ts +61 -0
  114. package/dist/remoting/extra_info.js +220 -0
  115. package/dist/remoting/headers.d.ts +758 -0
  116. package/dist/remoting/headers.js +1307 -0
  117. package/dist/remoting/heartbeat.d.ts +91 -0
  118. package/dist/remoting/heartbeat.js +227 -0
  119. package/dist/remoting/namespace.d.ts +14 -0
  120. package/dist/remoting/namespace.js +85 -0
  121. package/dist/remoting/pop_bodies.d.ts +58 -0
  122. package/dist/remoting/pop_bodies.js +214 -0
  123. package/dist/remoting/remotingCommand.d.ts +39 -0
  124. package/dist/remoting/remotingCommand.js +225 -0
  125. package/dist/remoting/route.d.ts +61 -0
  126. package/dist/remoting/route.js +288 -0
  127. package/dist/remoting/rpc_hooks.d.ts +31 -0
  128. package/dist/remoting/rpc_hooks.js +73 -0
  129. package/dist/remoting/serialize.d.ts +33 -0
  130. package/dist/remoting/serialize.js +372 -0
  131. package/dist/remoting/socks_proxy.d.ts +29 -0
  132. package/dist/remoting/socks_proxy.js +379 -0
  133. package/dist/remoting/static_topic.d.ts +49 -0
  134. package/dist/remoting/static_topic.js +244 -0
  135. package/dist/remoting/subscription.d.ts +65 -0
  136. package/dist/remoting/subscription.js +172 -0
  137. package/package.json +38 -4
@@ -0,0 +1,26 @@
1
+ import type { MQClient } from './mq_client.js';
2
+ import { PullResult } from './consumer_result.js';
3
+ import { MessageExt, MessageQueue } from '../common/message.js';
4
+ import { SubscriptionData } from '../common/subscriptionData.js';
5
+ import { FilterMessageHook } from './hook.js';
6
+ export declare class PullAPI {
7
+ private mqClient;
8
+ private group;
9
+ private unitMode;
10
+ accessChannel: string;
11
+ hooks: FilterMessageHook[];
12
+ private pullFromWhichNode;
13
+ connectBrokerByUser: boolean;
14
+ defaultBrokerId: number;
15
+ constructor(mqClient: MQClient, group: string);
16
+ recalculatePullFromWhichNode(mq: MessageQueue): number;
17
+ pullFromWhichNode(mq: MessageQueue): number | null;
18
+ updatePullFromWhichNode(mq: MessageQueue, brokerID: number): void;
19
+ forgetPullFromWhichNode(mq: MessageQueue): void;
20
+ pulledQueues(): MessageQueue[];
21
+ private findAddrInSubscribe;
22
+ pullKernel(mq: MessageQueue, offset: number, sub: SubscriptionData, sysFlag: number, commitOffset: number, maxMsgNums: number, suspendTimeoutMillis: number, timeoutMillis: number, requestCode?: number, maxMsgBytes?: number): Promise<PullResult>;
23
+ pullKernelLite(mq: MessageQueue, offset: number, sub: SubscriptionData, sysFlag: number, maxMsgNums: number, suspendTimeoutMillis: number, timeoutMillis: number): Promise<PullResult>;
24
+ processPullResult(mq: MessageQueue, result: PullResult, sub: SubscriptionData): PullResult;
25
+ }
26
+ export declare function clientSideTagFilter(sub: SubscriptionData, msgs: MessageExt[]): MessageExt[];
@@ -0,0 +1,264 @@
1
+ import { PullStatus, PullResult } from "./consumer_result.js";
2
+ import { PullMessageRequestHeader } from "../remoting/headers.js";
3
+ import { RemotingCommand } from "../remoting/remotingCommand.js";
4
+ import { RequestCode, ResponseCode } from "../remoting/codes.js";
5
+ import { PullSysFlag } from "../common/sysflag.js";
6
+ import { MessageQueue } from "../common/message.js";
7
+ import { MessageConst } from "../common/messageConst.js";
8
+ import { MixAll } from "../common/mixAll.js";
9
+ import { SubscriptionData, ExpressionType } from "../common/subscriptionData.js";
10
+ import { FilterMessageContext } from "./hook.js";
11
+ import { AccessChannelLocal } from "./trace_context.js";
12
+ import { decodeMessages, decodeInnerBatchMessages } from "../common/messageDecoder.js";
13
+ import { getLogger } from "../logging.js";
14
+ import { MQBrokerException } from "../remoting/exception.js";
15
+ import { mqKey } from "./offset_store.js";
16
+ const logger = getLogger('client.pull_api');
17
+ export class PullAPI {
18
+ mqClient;
19
+ group;
20
+ unitMode = false;
21
+ // Java ClientConfig#accessChannel, mirrored onto FilterMessageContext by callers.
22
+ // The pull/lite-pull facades set it before the first delivery.
23
+ accessChannel = AccessChannelLocal;
24
+ hooks = [];
25
+ // pullFromWhichNode maps mqKey -> the brokerId to ask next round.
26
+ pullFromWhichNode = new Map();
27
+ // connectBrokerByUser / defaultBrokerId mirror PullAPIWrapper's two fields: when the
28
+ // switch is on, recalculatePullFromWhichNode answers defaultBrokerId unconditionally and
29
+ // the suggestion table is never consulted. That is the only way to pin a lite-pull
30
+ // consumer to a slave (Java DefaultLitePullConsumer#setConnectBrokerByUser).
31
+ connectBrokerByUser = false;
32
+ defaultBrokerId = MixAll.MASTER_ID;
33
+ constructor(mqClient, group) {
34
+ this.mqClient = mqClient;
35
+ this.group = group;
36
+ }
37
+ // recalculatePullFromWhichNode: defaultBrokerId while the user pin is on, otherwise
38
+ // the table value, or MASTER_ID when the queue has no entry.
39
+ recalculatePullFromWhichNode(mq) {
40
+ if (this.connectBrokerByUser)
41
+ return this.defaultBrokerId;
42
+ const id = this.pullFromWhichNode.get(mqKey(mq));
43
+ return id === undefined ? MixAll.MASTER_ID : id;
44
+ }
45
+ pullFromWhichNode(mq) {
46
+ const id = this.pullFromWhichNode.get(mqKey(mq));
47
+ return id === undefined ? null : id;
48
+ }
49
+ updatePullFromWhichNode(mq, brokerID) {
50
+ this.pullFromWhichNode.set(mqKey(mq), brokerID);
51
+ }
52
+ // forgetPullFromWhichNode discards one queue's broker-selection record; the next lookup rebuilds from empty.
53
+ forgetPullFromWhichNode(mq) {
54
+ this.pullFromWhichNode.delete(mqKey(mq));
55
+ }
56
+ // pulledQueues turns the selection table's key set back into a MessageQueue
57
+ // list — i.e. "the assignment the consumer is actually running". mqKey is the
58
+ // topic@brokerName@queueId triple; neither part may contain '@' (guaranteed by
59
+ // Validators), so the split is unambiguous.
60
+ pulledQueues() {
61
+ const out = [];
62
+ for (const key of this.pullFromWhichNode.keys()) {
63
+ const first = key.indexOf('@');
64
+ const last = key.lastIndexOf('@');
65
+ if (first <= 0 || last <= first)
66
+ continue;
67
+ out.push(new MessageQueue(key.slice(0, first), key.slice(first + 1, last), parseInt(key.slice(last + 1), 10) || 0));
68
+ }
69
+ return out;
70
+ }
71
+ // findAddrInSubscribe returns (addr, isSlave) or null; isSlave is decided by
72
+ // the brokerId that ACTUALLY matched, not computed directly from the request
73
+ // id.
74
+ findAddrInSubscribe(brokerName, brokerId, onlyThisBroker) {
75
+ const addrs = this.mqClient.getBrokerAddrTable().get(brokerName);
76
+ if (!addrs || Object.keys(addrs).length === 0)
77
+ return null;
78
+ const snapshot = new Map();
79
+ for (const [id, addr] of Object.entries(addrs))
80
+ snapshot.set(parseInt(id, 10), addr);
81
+ const hit = snapshot.get(brokerId);
82
+ if (hit != null)
83
+ return { addr: hit, isSlave: brokerId !== MixAll.MASTER_ID };
84
+ if (brokerId !== MixAll.MASTER_ID) {
85
+ const next = snapshot.get(brokerId + 1);
86
+ if (next != null)
87
+ return { addr: next, isSlave: true };
88
+ }
89
+ if (!onlyThisBroker) {
90
+ let minID = 0;
91
+ let first = true;
92
+ for (const id of snapshot.keys()) {
93
+ if (first || id < minID) {
94
+ minID = id;
95
+ first = false;
96
+ }
97
+ }
98
+ return { addr: snapshot.get(minID), isSlave: minID !== MixAll.MASTER_ID };
99
+ }
100
+ return null;
101
+ }
102
+ // pullKernel: the pull kernel.
103
+ //
104
+ // When suspendTimeoutMillis > 0 the broker holds the request (LONG poll);
105
+ // short-poll callers pass 0 and clear the suspend bit in sysFlag.
106
+ async pullKernel(mq, offset, sub, sysFlag, commitOffset, maxMsgNums, suspendTimeoutMillis, timeoutMillis, requestCode = RequestCode.PULL_MESSAGE, maxMsgBytes = -1) {
107
+ const resolved = this.findAddrInSubscribe(mq.getBrokerName(), this.recalculatePullFromWhichNode(mq), false);
108
+ let addr;
109
+ let sysFlagFinal = sysFlag;
110
+ if (!resolved) {
111
+ await this.mqClient.updateTopicRouteInfoFromNameServer(mq.getTopic(), false).catch(() => { });
112
+ const retry = this.findAddrInSubscribe(mq.getBrokerName(), this.recalculatePullFromWhichNode(mq), false);
113
+ if (!retry)
114
+ throw new Error(`The broker[${mq.getBrokerName()}] not exist`);
115
+ addr = retry.addr;
116
+ if (retry.isSlave)
117
+ sysFlagFinal = PullSysFlag.clearCommitOffsetFlag(sysFlagFinal);
118
+ }
119
+ else {
120
+ addr = resolved.addr;
121
+ if (resolved.isSlave)
122
+ sysFlagFinal = PullSysFlag.clearCommitOffsetFlag(sysFlagFinal);
123
+ }
124
+ const header = new PullMessageRequestHeader();
125
+ header.consumerGroup = this.group;
126
+ header.topic = mq.getTopic();
127
+ header.queueId = mq.getQueueId();
128
+ header.queueOffset = offset;
129
+ header.maxMsgNums = maxMsgNums;
130
+ header.sysFlag = sysFlagFinal;
131
+ header.commitOffset = commitOffset;
132
+ header.suspendTimeoutMillis = suspendTimeoutMillis;
133
+ header.subVersion = sub.subVersion;
134
+ header.expressionType = sub.expressionType || ExpressionType.TAG;
135
+ header.maxMsgBytes = maxMsgBytes;
136
+ // Rule 2: the expression rides the wire only when the SUBSCRIPTION bit is
137
+ // on. The key must not be present at all when the bit is off.
138
+ if (PullSysFlag.hasSubscriptionFlag(sysFlagFinal)) {
139
+ header.subscription = sub.subString;
140
+ }
141
+ const request = RemotingCommand.createRequestCommand(requestCode, header);
142
+ const response = await this.mqClient.remotingClient.invokeSync(addr, request, timeoutMillis);
143
+ let status;
144
+ if (response.code === ResponseCode.SUCCESS)
145
+ status = PullStatus.FOUND;
146
+ else if (response.code === ResponseCode.PULL_NOT_FOUND)
147
+ status = PullStatus.NO_NEW_MSG;
148
+ else if (response.code === ResponseCode.PULL_OFFSET_MOVED)
149
+ status = PullStatus.OFFSET_ILLEGAL;
150
+ else if (response.code === ResponseCode.PULL_RETRY_IMMEDIATELY)
151
+ status = PullStatus.NO_MATCHED_MSG;
152
+ // The code rides on the exception: every caller of this kernel has to tell the
153
+ // broker's own throttle answer (215) from a system error or a dead connection,
154
+ // and a bare Error would leave the number only inside the message text, which
155
+ // silently disables that branch. The wording stays as informative as before.
156
+ else
157
+ throw new MQBrokerException(response.code, `pull failed: CODE ${response.code} ${response.remark || ''}`, addr);
158
+ const ext = response.extFields || {};
159
+ const num = (k, d) => (ext[k] != null ? parseInt(ext[k], 10) : d);
160
+ let found = [];
161
+ if (response.body && response.body.length > 0) {
162
+ found = decodeMessages(response.body, this.mqClient.decodeReadBody);
163
+ for (const msg of found) {
164
+ msg.setBrokerName(mq.getBrokerName());
165
+ msg.setQueueId(mq.getQueueId());
166
+ }
167
+ }
168
+ const suggest = ext['suggestWhichBrokerId'] != null ? parseInt(ext['suggestWhichBrokerId'], 10) : null;
169
+ return new PullResult(status, num('nextBeginOffset', 0), num('minOffset', 0), num('maxOffset', 0), found, suggest);
170
+ }
171
+ // pullKernelLite is the LITE_PULL_MESSAGE(361) flavour the lite pull
172
+ // consumer uses: identical header and response shape, and the caller has
173
+ // already set the FLAG_LITE_PULL_MESSAGE bit in sysFlag. The pull is always
174
+ // a SHORT poll with no inline offset commit, so commitOffset is fixed at 0.
175
+ // The suspend field still carries the consumer's configured broker-suspend
176
+ // budget: the request is a short poll because this loop is synchronous and
177
+ // must answer its caller, not because the budget is a constant.
178
+ //
179
+ // A TAG expression travels with subVersion 0: the broker re-derives the filter
180
+ // from the expression in the same request instead of matching it against a
181
+ // previously registered version. SQL92 keeps its own version.
182
+ async pullKernelLite(mq, offset, sub, sysFlag, maxMsgNums, suspendTimeoutMillis, timeoutMillis) {
183
+ let wireSub = sub;
184
+ if ((sub.expressionType || ExpressionType.TAG) === ExpressionType.TAG && sub.subVersion !== 0) {
185
+ wireSub = new SubscriptionData(sub.topic, sub.subString);
186
+ wireSub.tagsSet = sub.tagsSet;
187
+ wireSub.codeSet = sub.codeSet;
188
+ wireSub.expressionType = sub.expressionType;
189
+ wireSub.subVersion = 0;
190
+ }
191
+ return this.pullKernel(mq, offset, wireSub, sysFlag, 0, maxMsgNums, suspendTimeoutMillis, timeoutMillis, RequestCode.LITE_PULL_MESSAGE);
192
+ }
193
+ // processPullResult: must run on every response, not just FOUND — rule 3: the
194
+ // selection table is fed by every acknowledgement, and a missing field counts
195
+ // as master.
196
+ processPullResult(mq, result, sub) {
197
+ const brokerId = result.suggestWhichBrokerId != null ? result.suggestWhichBrokerId : MixAll.MASTER_ID;
198
+ this.updatePullFromWhichNode(mq, brokerId);
199
+ if (result.status !== PullStatus.FOUND || result.msgFoundList.length === 0)
200
+ return result;
201
+ // Unwrap inner batches before filtering so the tag check and the hooks see
202
+ // the individual messages.
203
+ let msgs = decodeInnerBatchMessages(result.msgFoundList);
204
+ msgs = clientSideTagFilter(sub, msgs);
205
+ if (this.hooks.length > 0) {
206
+ // FilterMessageHook MUST swallow exceptions and continue: the pull path
207
+ // silently skips filtered messages.
208
+ const ctx = new FilterMessageContext();
209
+ ctx.consumerGroup = this.group;
210
+ ctx.msgList = msgs;
211
+ ctx.mq = mq;
212
+ ctx.unitMode = this.unitMode;
213
+ ctx.accessChannel = this.accessChannel;
214
+ for (const hook of this.hooks.slice()) {
215
+ try {
216
+ hook.filterMessage(ctx);
217
+ }
218
+ catch (e) { /* swallowed by contract */ }
219
+ }
220
+ msgs = ctx.msgList;
221
+ }
222
+ for (const msg of msgs) {
223
+ if (msg.getProperty(MessageConst.PROPERTY_TRANSACTION_PREPARED) === 'true') {
224
+ const uniq = msg.getProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
225
+ if (uniq)
226
+ msg.setTransactionId(uniq);
227
+ }
228
+ msg.putProperty(MessageConst.PROPERTY_MIN_OFFSET, String(result.minOffset));
229
+ msg.putProperty(MessageConst.PROPERTY_MAX_OFFSET, String(result.maxOffset));
230
+ msg.setBrokerName(mq.getBrokerName());
231
+ }
232
+ result.msgFoundList = msgs;
233
+ return result;
234
+ }
235
+ }
236
+ // clientSideTagFilter: the second, string-level tag filter inside
237
+ // processPullResult. The guard's "tagsSet non-empty" check is exactly why
238
+ // FilterAPI's SUB_ALL branch must keep tagsSet EMPTY: subscribing to "*" means
239
+ // switching filtering off entirely, not filtering out every message.
240
+ //
241
+ // Exported because the POP round applies the same step to its FOUND answer: one
242
+ // rule, one implementation.
243
+ export function clientSideTagFilter(sub, msgs) {
244
+ // tagsSet is a Set in this implementation — use .size, not .length.
245
+ // `.length === 0` on a Set is always false, which would silently turn a '*'
246
+ // subscription (empty tagsSet -> filtering off) into "filter out everything".
247
+ const tagsSet = sub ? sub.tagsSet : null;
248
+ const empty = tagsSet == null ||
249
+ (typeof tagsSet.size === 'number' ? tagsSet.size === 0 : tagsSet.length === 0);
250
+ if (msgs.length === 0 || !sub || empty || sub.classFilterMode) {
251
+ return msgs;
252
+ }
253
+ const accepted = typeof tagsSet.has === 'function'
254
+ ? tagsSet : new Set(tagsSet);
255
+ const out = [];
256
+ for (const msg of msgs) {
257
+ const tags = msg.getProperty(MessageConst.PROPERTY_TAGS);
258
+ if (!tags)
259
+ continue;
260
+ if (accepted.has(tags))
261
+ out.push(msg);
262
+ }
263
+ return out;
264
+ }
@@ -0,0 +1,119 @@
1
+ import { PullAPI } from './pull_api.js';
2
+ import { MQClient } from './mq_client.js';
3
+ import type { OffsetStore } from './offset_store.js';
4
+ import { PullResult, MessageSelector } from './consumer_result.js';
5
+ import type { AllocateMessageQueueStrategy } from './allocate.js';
6
+ import { MessageQueue, MessageExt } from '../common/message.js';
7
+ import { SubscriptionData } from '../common/subscriptionData.js';
8
+ export interface PullCallback {
9
+ onSuccess(pullResult: PullResult): void;
10
+ onException(e: Error): void;
11
+ }
12
+ export declare class DefaultMQPullConsumer {
13
+ consumerGroup: string;
14
+ namespace: string;
15
+ namespaceV2: string | null;
16
+ nameServerAddr: string;
17
+ messageModel: string;
18
+ unitMode: boolean;
19
+ instanceName: string;
20
+ unitName: string;
21
+ enableStreamRequestType: boolean;
22
+ consumeType: string;
23
+ get subscriptionDataSet(): SubscriptionData[];
24
+ clientID: string;
25
+ mqClient: MQClient | null;
26
+ pullAPI: PullAPI | null;
27
+ offsetStore: OffsetStore | null;
28
+ pullBatchSize: number;
29
+ pullTimeoutMillis: number;
30
+ maxReconsumeTimes: number;
31
+ persistConsumerOffsetInterval: number;
32
+ useHeartbeatV2: boolean;
33
+ decodeReadBody: boolean;
34
+ mqClientApiTimeout: number;
35
+ enableConcurrentHeartbeat: boolean;
36
+ concurrentHeartbeatThreadPoolSize: number;
37
+ maxPageSizeInGetMetadata: number;
38
+ enableRebalance: boolean;
39
+ rebalanceWaitMillis: number;
40
+ rebalanceMinIntervalMillis: number;
41
+ allocateMessageQueueStrategy: AllocateMessageQueueStrategy;
42
+ messageQueueListener: ((topic: string, mqAll: MessageQueue[], mqDivided: MessageQueue[]) => void) | null;
43
+ private rebalanceTable;
44
+ private registerTopics;
45
+ private _rebalanceTimer;
46
+ private _rebalanceActive;
47
+ private subscription;
48
+ started: boolean;
49
+ private _producer;
50
+ constructor(consumerGroup?: string);
51
+ setNamesrvAddr(addr: string): this;
52
+ setNamespace(ns: string): this;
53
+ setNamespaceV2(ns: string | null): this;
54
+ getNamespaceV2(): string | null;
55
+ setMessageModel(model: string): this;
56
+ setInstanceName(name: string): this;
57
+ setUnitName(name: string): this;
58
+ setPullBatchSize(n: number): this;
59
+ setPullTimeoutMillis(ms: number): this;
60
+ setMaxReconsumeTimes(n: number): this;
61
+ setPersistConsumerOffsetInterval(ms: number): this;
62
+ getPersistConsumerOffsetInterval(): number;
63
+ setUseHeartbeatV2(enable: boolean): this;
64
+ getUseHeartbeatV2(): boolean;
65
+ setDecodeReadBody(enable: boolean): this;
66
+ getDecodeReadBody(): boolean;
67
+ setMqClientApiTimeout(ms: number): this;
68
+ getMqClientApiTimeout(): number;
69
+ setEnableConcurrentHeartbeat(enable: boolean): this;
70
+ getEnableConcurrentHeartbeat(): boolean;
71
+ setConcurrentHeartbeatThreadPoolSize(size: number): this;
72
+ getConcurrentHeartbeatThreadPoolSize(): number;
73
+ setMaxPageSizeInGetMetadata(size: number): this;
74
+ getMaxPageSizeInGetMetadata(): number;
75
+ setEnableRebalance(enable: boolean): this;
76
+ isEnableRebalance(): boolean;
77
+ setRebalanceWaitMillis(ms: number): this;
78
+ setRebalanceMinIntervalMillis(ms: number): this;
79
+ setAllocateMessageQueueStrategy(strategy: AllocateMessageQueueStrategy): this;
80
+ setMessageQueueListener(listener: ((topic: string, mqAll: MessageQueue[], mqDivided: MessageQueue[]) => void) | null): this;
81
+ registerMessageQueueListener(topic: string, listener: ((topic: string, mqAll: MessageQueue[], mqDivided: MessageQueue[]) => void) | null): this;
82
+ getRegisterTopics(): Set<string>;
83
+ getRebalanceTable(): Map<string, MessageQueue[]>;
84
+ getConsumerGroup(): string;
85
+ isStarted(): boolean;
86
+ subscribe(topic: string, subExpression?: string | MessageSelector): this;
87
+ _withNamespace(resource: string): string;
88
+ private _queueWithNamespace;
89
+ private _bareQueue;
90
+ private _buildSub;
91
+ start(): Promise<void>;
92
+ shutdown(): Promise<void>;
93
+ fetchPublishMessageQueues(topic: string): Promise<MessageQueue[]>;
94
+ fetchSubscribeMessageQueues(topic: string): Promise<MessageQueue[]>;
95
+ private routeOf;
96
+ pull(mq: MessageQueue, subExpression: string | MessageSelector | null, offset: number, maxNums: number, timeoutMillis?: number): Promise<PullResult>;
97
+ pullAsync(mq: MessageQueue, subExpression: string | MessageSelector | null, offset: number, maxNums: number, callback: PullCallback, timeoutMillis?: number): void;
98
+ pullBlockIfNotFound(mq: MessageQueue, subExpression: string | MessageSelector | null, offset: number, maxNums: number, timeoutMillis?: number, suspendTimeoutMillis?: number): Promise<PullResult>;
99
+ private _pullImpl;
100
+ updateConsumeOffset(mq: MessageQueue, offset: number): void;
101
+ fetchConsumeOffset(mq: MessageQueue, fromStore: boolean): Promise<number>;
102
+ private _warmQueueRoute;
103
+ persistConsumeOffset(): Promise<void>;
104
+ persistConsumerOffset(): Promise<void>;
105
+ maxOffset(mq: MessageQueue): Promise<number>;
106
+ fetchMessageQueuesInBalance(topic: string): Promise<MessageQueue[]>;
107
+ private _fetchMessageQueuesInBalance;
108
+ private _getConsumerIdsFor;
109
+ private _rebalanceTopics;
110
+ private _startRebalanceLoop;
111
+ doRebalance(): Promise<boolean>;
112
+ rebalanceByTopic(topic: string): Promise<boolean>;
113
+ private _sameMqSet;
114
+ notifyQueueChanged(topic: string, mqAll: MessageQueue[], mqDivided: MessageQueue[]): void;
115
+ sendMessageBack(msg: MessageExt, delayLevel?: number): Promise<void>;
116
+ private _sendRetryMessage;
117
+ private _innerProducer;
118
+ viewMessage(topic: string, msgId: string): Promise<MessageExt>;
119
+ }