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,288 @@
1
+ import { isWaitStoreMsgOK } from "../common/message.js";
2
+ import { MessageBatch } from "../common/message.js";
3
+ import { MessageConst } from "../common/messageConst.js";
4
+ import { MessageAccessor } from "../common/message_accessor.js";
5
+ import { MixAll } from "../common/mixAll.js";
6
+ import { SendResult } from "./send_result.js";
7
+ export const DEFAULT_TOTAL_HOLD_SIZE = 32 * 1024 * 1024; // 32 MB
8
+ export const DEFAULT_HOLD_SIZE = 32 * 1024; // 32 KB
9
+ export const DEFAULT_HOLD_MS = 10;
10
+ export class AggregateKey {
11
+ topic;
12
+ mq;
13
+ waitStoreMsgOK;
14
+ tag;
15
+ constructor(topic, mq, waitStoreMsgOK, tag) {
16
+ this.topic = topic;
17
+ this.mq = mq;
18
+ this.waitStoreMsgOK = waitStoreMsgOK;
19
+ this.tag = tag;
20
+ }
21
+ // Keys are comparable by (topic, queue hashcode, waitStoreMsgOK, tag).
22
+ keyString() {
23
+ return `${this.topic}\u0000${this.mq.hashcode()}\u0000${this.waitStoreMsgOK ? 1 : 0}\u0000${this.tag ?? ''}`;
24
+ }
25
+ equals(other) {
26
+ return this.topic === other.topic &&
27
+ this.mq.equals(other.mq) &&
28
+ this.waitStoreMsgOK === other.waitStoreMsgOK &&
29
+ this.tag === other.tag;
30
+ }
31
+ }
32
+ // One message that joined the accumulator, plus the future its own caller
33
+ // waits on. The batch answer is split back onto every member, so a caller that
34
+ // handed over a single message always gets that message's result — not the
35
+ // group's.
36
+ export class AccumulatedSend {
37
+ message;
38
+ mq;
39
+ promise;
40
+ settleResult = () => { };
41
+ settleError = () => { };
42
+ constructor(message, mq) {
43
+ this.message = message;
44
+ this.mq = mq;
45
+ this.promise = new Promise((resolve, reject) => {
46
+ this.settleResult = resolve;
47
+ this.settleError = reject;
48
+ });
49
+ }
50
+ complete(result) {
51
+ this.settleResult(result);
52
+ }
53
+ completeExceptionally(err) {
54
+ this.settleError(err);
55
+ }
56
+ }
57
+ export class MessageAccumulation {
58
+ entries;
59
+ totalSize;
60
+ constructor() {
61
+ this.entries = [];
62
+ this.totalSize = 0;
63
+ }
64
+ add(entry, size) {
65
+ this.entries.push(entry);
66
+ this.totalSize += size;
67
+ }
68
+ get messages() { return this.entries.map((entry) => entry.message); }
69
+ get count() { return this.entries.length; }
70
+ get size() { return this.totalSize; }
71
+ isEmpty() { return this.entries.length === 0; }
72
+ clear() { this.entries = []; this.totalSize = 0; }
73
+ // Settle the whole group with the answer its batch got: each member receives
74
+ // its own SendResult built from the shared batch outcome.
75
+ complete(batchResult) {
76
+ const results = splitSendResults(batchResult, this.messages);
77
+ for (let i = 0; i < this.entries.length; i++)
78
+ this.entries[i].complete(results[i]);
79
+ }
80
+ // The group could not leave (no route, no queue, the broker refused it):
81
+ // every waiting caller learns that instead of hanging.
82
+ fail(err) {
83
+ for (const entry of this.entries)
84
+ entry.completeExceptionally(err);
85
+ }
86
+ }
87
+ export class ProduceAccumulator {
88
+ maxHoldSize;
89
+ holdMs;
90
+ clientId;
91
+ accumulator;
92
+ sender;
93
+ timer;
94
+ // True between stop() and the next start(). A group opened after a stop has no
95
+ // timer left to drain it, so nothing may hand a caller's message to it.
96
+ stopped;
97
+ constructor(clientId, maxHoldSize = DEFAULT_HOLD_SIZE, holdMs = DEFAULT_HOLD_MS) {
98
+ this.clientId = clientId;
99
+ this.maxHoldSize = maxHoldSize;
100
+ this.holdMs = holdMs;
101
+ this.accumulator = new Map();
102
+ this.sender = null;
103
+ this.timer = null;
104
+ this.stopped = false;
105
+ }
106
+ setSender(fn) {
107
+ this.sender = fn;
108
+ }
109
+ // The two gates are protocol-facing limits (a batch outside them is not going
110
+ // to be accepted downstream), so an out-of-range value is refused here rather
111
+ // than quietly moving traffic to another path.
112
+ setMaxHoldSize(size) {
113
+ if (size < 1 || size > 2 * 1024 * 1024) {
114
+ throw new Error(`batchMaxBytes expect between 1B and 2MB, but get ${size}!`);
115
+ }
116
+ this.maxHoldSize = size;
117
+ }
118
+ setHoldMs(ms) {
119
+ if (ms < 1 || ms > 30 * 1000) {
120
+ throw new Error(`batchMaxDelayMs expect between 1ms and 30s, but get ${ms}!`);
121
+ }
122
+ this.holdMs = ms;
123
+ // The period is captured when the timer is built, so a running daemon is
124
+ // rebuilt for the new period to take effect from the next tick.
125
+ if (this.timer != null) {
126
+ clearInterval(this.timer);
127
+ this.timer = null;
128
+ this.start();
129
+ }
130
+ }
131
+ // Whether a message may ride a batch at all. A packed batch is never packed
132
+ // again, a delayed / timed message has to reach its own schedule, a
133
+ // transaction half message has to stay individually addressable for the
134
+ // broker's check-back, a retry-topic message belongs to one consumer group,
135
+ // and a body over the hold size can never fit inside a group that is flushed
136
+ // at that size — all of those go out on their own.
137
+ isBatchable(msg) {
138
+ if (msg instanceof MessageBatch)
139
+ return false;
140
+ if (MixAll.isRetryTopic(msg.getTopic()))
141
+ return false;
142
+ if (MessageAccessor.isTransactionPrepared(msg))
143
+ return false;
144
+ // A message already stamped with a producer group is the half-message kind:
145
+ // the broker locates its transactional connection by group, so it cannot
146
+ // ride an envelope addressed by whoever else's group the batch happens to get.
147
+ if (msg.getProperty(MessageConst.PROPERTY_PRODUCER_GROUP) != null)
148
+ return false;
149
+ const delayLevel = msg.getDelayTimeLevel();
150
+ if (delayLevel != null && parseInt(delayLevel, 10) > 0)
151
+ return false;
152
+ // Value checks, not presence: a 0 under one of these names asks for no schedule, so the
153
+ // message still belongs in a group.
154
+ for (const raw of [msg.getDelayTimeSec(), msg.getDelayTimeMs(), msg.getDeliverTimeMs()]) {
155
+ if (raw != null && parseInt(raw, 10) > 0)
156
+ return false;
157
+ }
158
+ return msg.getBody().length <= this.maxHoldSize;
159
+ }
160
+ // Hand one message to the group of its key. `future` settles with this
161
+ // message's own result; `flushNow` is the group that crossed the hold size
162
+ // (removed from the table) and should leave immediately instead of waiting
163
+ // for the hold timer.
164
+ //
165
+ // A stopped accumulator has no timer left, so a group opened now would never
166
+ // drain and its caller would wait forever; refusing here is what lets the
167
+ // caller take the direct send path instead.
168
+ accumulate(msg, mq) {
169
+ if (this.stopped)
170
+ throw new Error('producer accumulator is stopped');
171
+ const tag = msg.getTags();
172
+ const key = new AggregateKey(msg.getTopic(), mq, isWaitStoreMsgOK(msg), tag);
173
+ const k = key.keyString();
174
+ let acc = this.accumulator.get(k);
175
+ if (acc == null) {
176
+ acc = new MessageAccumulation();
177
+ this.accumulator.set(k, acc);
178
+ }
179
+ const future = new AccumulatedSend(msg, mq);
180
+ const size = msg.getBody() ? msg.getBody().length : 0;
181
+ acc.add(future, size);
182
+ if (acc.size >= this.maxHoldSize) {
183
+ this.accumulator.delete(k);
184
+ return { future, flushNow: acc };
185
+ }
186
+ return { future, flushNow: null };
187
+ }
188
+ // Drain all pending accumulations (used when flushing on a timer or shutdown).
189
+ drain() {
190
+ const out = [];
191
+ for (const acc of this.accumulator.values()) {
192
+ if (!acc.isEmpty())
193
+ out.push(acc);
194
+ }
195
+ this.accumulator.clear();
196
+ return out;
197
+ }
198
+ size() { return this.accumulator.size; }
199
+ isStopped() { return this.stopped; }
200
+ start() {
201
+ // (Re)starting always clears the stopped mark: a facade may wire a fresh
202
+ // sender onto an accumulator that an earlier shutdown stopped, and the
203
+ // buffer has to accept traffic again.
204
+ this.stopped = false;
205
+ if (this.timer != null)
206
+ return;
207
+ this.timer = setInterval(() => { void this.flushPending(); }, Math.max(1, this.holdMs));
208
+ // Keep the daemon off the event loop so a settled producer cannot by itself
209
+ // hold the process open.
210
+ const timer = this.timer;
211
+ if (typeof timer.unref === 'function')
212
+ timer.unref();
213
+ }
214
+ // Hand every buffered group to the sender. Each group is settled exactly once:
215
+ // the sender settles it with the batch answer, and only if the sender itself
216
+ // throws (before settling) does the group fail with that error — a stranded
217
+ // group would leave its callers' send promises pending forever.
218
+ async flushPending() {
219
+ if (this.sender == null)
220
+ return;
221
+ for (const acc of this.drain()) {
222
+ try {
223
+ await this.sender(acc);
224
+ }
225
+ catch (e) {
226
+ acc.fail(e instanceof Error ? e : new Error(String(e)));
227
+ }
228
+ }
229
+ }
230
+ // Stopping flushes what is still buffered rather than dropping it: without a
231
+ // sender there is nothing left that could settle these groups, so they fail
232
+ // instead of hanging.
233
+ stop() {
234
+ this.stopped = true;
235
+ if (this.timer != null) {
236
+ clearInterval(this.timer);
237
+ this.timer = null;
238
+ }
239
+ if (this.sender == null) {
240
+ for (const acc of this.drain())
241
+ acc.fail(new Error('producer accumulator stopped with the batch unsent'));
242
+ return;
243
+ }
244
+ void this.flushPending();
245
+ }
246
+ }
247
+ const _ACCUMULATORS = new Map();
248
+ export function getOrCreateProduceAccumulator(clientId) {
249
+ let acc = _ACCUMULATORS.get(clientId);
250
+ if (acc == null) {
251
+ acc = new ProduceAccumulator(clientId);
252
+ _ACCUMULATORS.set(clientId, acc);
253
+ }
254
+ return acc;
255
+ }
256
+ // Split one batch SendResult into per-message SendResults: the group shares the
257
+ // queue and the store status, every member gets the offsets its own stored
258
+ // record carries, and every member keeps its OWN client message id (its
259
+ // UNIQ_KEY, stamped before it joined the group).
260
+ export function splitSendResults(batchResult, msgs) {
261
+ // The store answers a group with one entry per member for the two id kinds
262
+ // independently: the message-id field can stay the single envelope id while
263
+ // the physical-offset field already lists one id per member. Each list is
264
+ // matched member by member only when it really has one element per member.
265
+ const idParts = String(batchResult.msgId ?? '').split(',');
266
+ const offsetParts = String(batchResult.offsetMsgId ?? '').split(',');
267
+ const idsSplit = idParts.length === msgs.length && msgs.length > 1;
268
+ const offsetsSplit = offsetParts.length === msgs.length && msgs.length > 1;
269
+ const out = [];
270
+ for (let i = 0; i < msgs.length; i++) {
271
+ const msg = msgs[i];
272
+ const uniqKey = msg.getProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
273
+ const msgId = idsSplit
274
+ ? idParts[i]
275
+ : (uniqKey != null && String(uniqKey).length > 0 ? String(uniqKey) : batchResult.msgId);
276
+ // The group occupies consecutive queue offsets in its queue, the envelope's
277
+ // answer being the first of them; member i sits i further along, which is
278
+ // the offset a consumer later reads back for that body.
279
+ const queueOffset = batchResult.queueOffset + i;
280
+ out.push(new SendResult(batchResult.sendStatus, msgId, batchResult.messageQueue, queueOffset, batchResult.transactionId, offsetsSplit ? offsetParts[i] : batchResult.offsetMsgId, batchResult.regionId, batchResult.traceOn, batchResult.recallHandle));
281
+ }
282
+ return out;
283
+ }
284
+ export default {
285
+ ProduceAccumulator, AggregateKey, MessageAccumulation,
286
+ getOrCreateProduceAccumulator, splitSendResults,
287
+ DEFAULT_TOTAL_HOLD_SIZE, DEFAULT_HOLD_SIZE, DEFAULT_HOLD_MS,
288
+ };
@@ -0,0 +1,231 @@
1
+ import { RemotingCommand } from '../remoting/remotingCommand.js';
2
+ import { Message, MessageQueue, MessageExt } from '../common/message.js';
3
+ import { AclRPCHook } from '../remoting/acl.js';
4
+ import type { SocksProxyConfig } from '../remoting/socks_proxy.js';
5
+ import { SendResult, TransactionSendResult } from './send_result.js';
6
+ import { MQClient, TopicPublishInfo } from './mq_client.js';
7
+ import { MQFaultStrategy } from './latency.js';
8
+ import type { AsyncTraceDispatcher } from './trace_dispatcher.js';
9
+ import { RequestResponseFuture } from './request_reply.js';
10
+ import type { RequestCallbackLike } from './request_reply.js';
11
+ export declare abstract class MessageQueueSelector {
12
+ abstract select(msgs: Message | Message[], mqList: MessageQueue[], arg: any): MessageQueue | null;
13
+ }
14
+ export declare class SelectMessageQueueByHash extends MessageQueueSelector {
15
+ select(_msgs: Message | Message[], mqList: MessageQueue[], arg: any): MessageQueue | null;
16
+ }
17
+ export declare class SelectMessageQueueByRandom extends MessageQueueSelector {
18
+ select(_msgs: Message | Message[], mqList: MessageQueue[], _arg: any): MessageQueue | null;
19
+ }
20
+ export declare class SelectMessageQueueByMachineRoom extends MessageQueueSelector {
21
+ select(_msgs: Message | Message[], mqList: MessageQueue[], arg: any): MessageQueue | null;
22
+ }
23
+ export type SendCallback = (sendResult: SendResult | null, err: Error | null) => void;
24
+ export declare const LocalTransactionState: {
25
+ COMMIT_MESSAGE: number;
26
+ ROLLBACK_MESSAGE: number;
27
+ UNKNOW: number;
28
+ };
29
+ export declare function classifySendMessageType(msg: Message): string;
30
+ export declare abstract class TransactionListener {
31
+ executeLocalTransaction(msg: Message, arg: any): number;
32
+ checkLocalTransaction(msg: Message): number;
33
+ }
34
+ export declare class DefaultMQProducer {
35
+ producerGroup: string;
36
+ createTopicKey: string;
37
+ defaultTopicQueueNums: number;
38
+ sendMsgTimeout: number;
39
+ sendMsgMaxTimeoutPerRequest: number;
40
+ compressMsgBodyOverHowmuch: number;
41
+ maxMessageSize: number;
42
+ retryTimesWhenSendFailed: number;
43
+ namespace: string | null;
44
+ namespaceV2: string | null;
45
+ namesrvAddr: string | null;
46
+ tlsEnable: boolean;
47
+ tlsOptions: {
48
+ caCert?: string;
49
+ clientCert?: string;
50
+ clientKey?: string;
51
+ serverName?: string;
52
+ } | null;
53
+ socksProxyConfig: SocksProxyConfig | null;
54
+ rpcHook: AclRPCHook | null;
55
+ accessChannel: string;
56
+ unitName: string | null;
57
+ instanceName: string;
58
+ sendLatencyFaultEnable: boolean;
59
+ heartbeatIntervalMillis: number;
60
+ autoBatch: boolean;
61
+ batchMaxBytes: number;
62
+ batchMaxDelayMs: number;
63
+ retryResponseCodes: Set<number>;
64
+ retryAnotherBrokerWhenNotStoreOK: boolean;
65
+ enableTrace: boolean;
66
+ traceTopic: string | null;
67
+ compressType: number;
68
+ sendMessageWithVIPChannel: boolean;
69
+ retryTimesWhenSendAsyncFailed: number;
70
+ compressLevel: number;
71
+ startDetectorEnable: boolean;
72
+ enableTraceContext: boolean;
73
+ useHeartbeatV2: boolean;
74
+ decodeReadBody: boolean;
75
+ mqClientApiTimeout: number;
76
+ enableConcurrentHeartbeat: boolean;
77
+ concurrentHeartbeatThreadPoolSize: number;
78
+ maxPageSizeInGetMetadata: number;
79
+ client: MQClient | null;
80
+ mqFaultStrategy: MQFaultStrategy;
81
+ producerClientId: string;
82
+ _traceDispatcher: AsyncTraceDispatcher | null;
83
+ private _traceHook;
84
+ private _recallTraceHook;
85
+ private _accumulator;
86
+ enableBackpressureForAsyncMode: boolean;
87
+ backPressureForAsyncSendNum: number;
88
+ backPressureForAsyncSendSize: number;
89
+ private _semaphoreAsyncSendNum;
90
+ private _semaphoreAsyncSendSize;
91
+ constructor(producerGroup?: string);
92
+ private _buildClientId;
93
+ _withNamespace(resource: string): string;
94
+ private _wrapMessageTopic;
95
+ _checkLegalTopic(topic: string): void;
96
+ setNamesrvAddr(addr: string): this;
97
+ setNamespace(ns: string): this;
98
+ setNamespaceV2(ns: string | null): this;
99
+ getNamespaceV2(): string | null;
100
+ setAccessChannel(channel: string): this;
101
+ getAccessChannel(): string;
102
+ setUnitName(name: string): this;
103
+ setInstanceName(name: string): this;
104
+ getInstanceName(): string;
105
+ setTlsEnable(enable: boolean): this;
106
+ setTlsOptions(opts: {
107
+ caCert?: string;
108
+ clientCert?: string;
109
+ clientKey?: string;
110
+ serverName?: string;
111
+ } | null): this;
112
+ setSocksProxyConfig(config: SocksProxyConfig | null): this;
113
+ getSocksProxyConfig(): SocksProxyConfig | null;
114
+ setSendMsgTimeout(ms: number): this;
115
+ setSendMsgMaxTimeoutPerRequest(ms: number): this;
116
+ getSendMsgMaxTimeoutPerRequest(): number;
117
+ setEnableTrace(enable: boolean): this;
118
+ setUseHeartbeatV2(enable: boolean): this;
119
+ getUseHeartbeatV2(): boolean;
120
+ setDecodeReadBody(enable: boolean): this;
121
+ getDecodeReadBody(): boolean;
122
+ setMqClientApiTimeout(ms: number): this;
123
+ getMqClientApiTimeout(): number;
124
+ setEnableConcurrentHeartbeat(enable: boolean): this;
125
+ getEnableConcurrentHeartbeat(): boolean;
126
+ setConcurrentHeartbeatThreadPoolSize(size: number): this;
127
+ getConcurrentHeartbeatThreadPoolSize(): number;
128
+ setMaxPageSizeInGetMetadata(size: number): this;
129
+ getMaxPageSizeInGetMetadata(): number;
130
+ setTraceTopic(topic: string): this;
131
+ setCompressType(compressType: string | number): this;
132
+ setCompressMsgBodyOverHowmuch(howmuch: number): this;
133
+ setSendMessageWithVIPChannel(enable: boolean): this;
134
+ isSendMessageWithVIPChannel(): boolean;
135
+ setRetryTimesWhenSendAsyncFailed(n: number): this;
136
+ getRetryTimesWhenSendAsyncFailed(): number;
137
+ setRetryTimesWhenSendFailed(n: number): this;
138
+ getRetryTimesWhenSendFailed(): number;
139
+ setRetryAnotherBrokerWhenNotStoreOK(enable: boolean): this;
140
+ getRetryAnotherBrokerWhenNotStoreOK(): boolean;
141
+ setAutoBatch(enable: boolean): this;
142
+ isAutoBatch(): boolean;
143
+ setHeartbeatIntervalMillis(ms: number): this;
144
+ getHeartbeatIntervalMillis(): number;
145
+ setRetryResponseCodes(codes: Iterable<number>): this;
146
+ getRetryResponseCodes(): Set<number>;
147
+ addRetryResponseCode(code: number): this;
148
+ removeRetryResponseCode(code: number): this;
149
+ isRetryResponseCode(code: number | null | undefined): boolean;
150
+ setBatchMaxBytes(bytes: number): this;
151
+ getBatchMaxBytes(): number;
152
+ setBatchMaxDelayMs(ms: number): this;
153
+ getBatchMaxDelayMs(): number;
154
+ setCompressLevel(level: number): this;
155
+ getCompressLevel(): number;
156
+ setStartDetectorEnable(enable: boolean): this;
157
+ setEnableBackpressureForAsyncMode(enable: boolean): this;
158
+ isEnableBackpressureForAsyncMode(): boolean;
159
+ setEnableTraceContext(enable: boolean): this;
160
+ isEnableTraceContext(): boolean;
161
+ setBackPressureForAsyncSendNum(num: number): this;
162
+ setBackPressureForAsyncSendSize(size: number): this;
163
+ getSemaphoreAsyncSendNumAvailablePermits(): number;
164
+ getSemaphoreAsyncSendSizeAvailablePermits(): number;
165
+ getBackPressureForAsyncSendNum(): number;
166
+ getBackPressureForAsyncSendSize(): number;
167
+ _acquireAsyncPermits(msg: Message, timeoutMillis: number, begin: number): Promise<number>;
168
+ private _releaseAsyncPermits;
169
+ start(): Promise<void>;
170
+ shutdown(): void;
171
+ tryToCompressMessage(msg: Message): boolean;
172
+ _tryToFindTopicPublishInfo(topic: string): Promise<TopicPublishInfo | null>;
173
+ private _lastRouteError;
174
+ private _routeFailureSuffix;
175
+ _selectOneMessageQueue(tpInfo: TopicPublishInfo, lastBrokerName: string | null): MessageQueue | null;
176
+ buildSendRequest(msg: Message, mq: MessageQueue): RemotingCommand;
177
+ private _sendAddr;
178
+ sendKernelImpl(msg: Message, mq: MessageQueue, communicationMode: number, sendCallback: SendCallback | null, tpInfo: TopicPublishInfo, timeoutMillis?: number): Promise<SendResult | null>;
179
+ private _sendAsyncKernel;
180
+ _sendWithHooks(msg: Message, mq: MessageQueue, communicationMode: number, sendCallback: SendCallback | null, tpInfo: TopicPublishInfo, timeoutMillis?: number): Promise<SendResult | null>;
181
+ _sendDefaultImpl(msg: Message, communicationMode: number, sendCallback: SendCallback | null, timeoutMillis: number): Promise<SendResult | null>;
182
+ send(msg: Message, timeoutMillis?: number): Promise<SendResult>;
183
+ sendOneway(msg: Message, timeoutMillis?: number): Promise<void>;
184
+ sendAsync(msg: Message, sendCallback: SendCallback, timeoutMillis?: number): Promise<void>;
185
+ _sendSelectImpl(msg: Message, selector: MessageQueueSelector, arg: any, communicationMode: number, sendCallback: SendCallback | null, timeoutMillis: number): Promise<SendResult | null>;
186
+ sendBySelector(msg: Message, selector: MessageQueueSelector, arg: any, timeoutMillis?: number): Promise<SendResult>;
187
+ sendMessageInTransaction(msg: Message, listener?: TransactionListener | null, arg?: any, timeoutMillis?: number): Promise<TransactionSendResult>;
188
+ private _endTransaction;
189
+ _prepareSendRequest(msg: Message, timeoutMillis: number): Promise<void>;
190
+ _waitResponse(msg: Message, timeoutMillis: number, future: RequestResponseFuture, cost: number): Promise<Message>;
191
+ request(msg: Message, timeoutMillis?: number): Promise<Message>;
192
+ requestBySelector(msg: Message, selector: MessageQueueSelector, arg: any, timeoutMillis?: number): Promise<Message>;
193
+ requestByMq(msg: Message, mq: MessageQueue, timeoutMillis?: number): Promise<Message>;
194
+ requestAsync(msg: Message, requestCallback: RequestCallbackLike, timeoutMillis?: number): void;
195
+ _requestAsyncDefault(msg: Message, requestCallback: RequestCallbackLike, timeoutMillis: number): Promise<void>;
196
+ requestAsyncBySelector(msg: Message, selector: MessageQueueSelector, arg: any, requestCallback: RequestCallbackLike, timeoutMillis?: number): void;
197
+ _requestAsyncBySelector(msg: Message, selector: MessageQueueSelector, arg: any, requestCallback: RequestCallbackLike, timeoutMillis: number): Promise<void>;
198
+ requestAsyncByMq(msg: Message, mq: MessageQueue, requestCallback: RequestCallbackLike, timeoutMillis?: number): void;
199
+ _requestAsyncByMq(msg: Message, mq: MessageQueue, requestCallback: RequestCallbackLike, timeoutMillis: number): Promise<void>;
200
+ _requestFail(correlationId: string): void;
201
+ static resolveRequestReply(correlationId: string, replyMsg: Message): void;
202
+ reply(requestMsg: Message, body: Buffer | string, timeoutMillis?: number): Promise<SendResult>;
203
+ recallMessage(topic: string, recallHandle: string): Promise<string>;
204
+ createTopic(topic: string, key?: string, queueNums?: number): Promise<void>;
205
+ maxOffset(topic: string, queueId: number): Promise<number>;
206
+ private _wireAccumulator;
207
+ private _canAutoBatch;
208
+ private _sendByAccumulator;
209
+ private _flushAccumulation;
210
+ getMQClient(): MQClient | null;
211
+ getProducerGroup(): string;
212
+ viewMessage(topic: string, msgId: string): Promise<MessageExt>;
213
+ }
214
+ export declare class TransactionMQProducer extends DefaultMQProducer {
215
+ transactionListener: TransactionListener | null;
216
+ constructor(producerGroup?: string, transactionListener?: TransactionListener | null);
217
+ }
218
+ declare const _default: {
219
+ DefaultMQProducer: typeof DefaultMQProducer;
220
+ TransactionMQProducer: typeof TransactionMQProducer;
221
+ MessageQueueSelector: typeof MessageQueueSelector;
222
+ SelectMessageQueueByHash: typeof SelectMessageQueueByHash;
223
+ SelectMessageQueueByRandom: typeof SelectMessageQueueByRandom;
224
+ LocalTransactionState: {
225
+ COMMIT_MESSAGE: number;
226
+ ROLLBACK_MESSAGE: number;
227
+ UNKNOW: number;
228
+ };
229
+ TransactionListener: typeof TransactionListener;
230
+ };
231
+ export default _default;