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,214 @@
1
+ import { encodeMessages } from "./messageDecoder.js";
2
+ function _strHash(s) {
3
+ let h = 0;
4
+ for (let i = 0; i < s.length; i++)
5
+ h = (Math.imul(31, h) + s.charCodeAt(i)) | 0;
6
+ return h;
7
+ }
8
+ function _cInt32(x) { return x | 0; }
9
+ export class MessageQueue {
10
+ topic;
11
+ brokerName;
12
+ queueId;
13
+ constructor(topic = '', brokerName = '', queueId = 0) {
14
+ this.topic = topic;
15
+ this.brokerName = brokerName;
16
+ this.queueId = queueId;
17
+ }
18
+ getTopic() { return this.topic; }
19
+ setTopic(t) { this.topic = t; }
20
+ getBrokerName() { return this.brokerName; }
21
+ setBrokerName(b) { this.brokerName = b; }
22
+ getQueueId() { return this.queueId; }
23
+ getQueueIdStr() { return String(this.queueId); }
24
+ setQueueId(q) { this.queueId = q; }
25
+ hashcode() {
26
+ return _cInt32(Math.imul(Math.imul(31 + _strHash(this.brokerName), 31) + this.queueId, 31) + _strHash(this.topic));
27
+ }
28
+ equals(other) {
29
+ return other instanceof MessageQueue && this.topic === other.topic &&
30
+ this.brokerName === other.brokerName && this.queueId === other.queueId;
31
+ }
32
+ compareTo(other) {
33
+ if (this.topic !== other.topic)
34
+ return this.topic < other.topic ? -1 : 1;
35
+ if (this.brokerName !== other.brokerName)
36
+ return this.brokerName < other.brokerName ? -1 : 1;
37
+ if (this.queueId !== other.queueId)
38
+ return this.queueId < other.queueId ? -1 : 1;
39
+ return 0;
40
+ }
41
+ toString() { return `MessageQueue [topic=${this.topic}, brokerName=${this.brokerName}, queueId=${this.queueId}]`; }
42
+ }
43
+ export function isWaitStoreMsgOK(msg) {
44
+ const v = msg.getWaitStoreMsgOK ? msg.getWaitStoreMsgOK() : null;
45
+ if (v == null)
46
+ return true;
47
+ return String(v).toLowerCase() === 'true';
48
+ }
49
+ export class Message {
50
+ topic;
51
+ flag;
52
+ properties;
53
+ body;
54
+ transactionId;
55
+ constructor(topic = '', body = null, tags = null, keys = null, flag = 0) {
56
+ this.topic = topic;
57
+ this.flag = flag;
58
+ this.properties = {};
59
+ this.body = body == null ? Buffer.alloc(0) : (Buffer.isBuffer(body) ? body : Buffer.from(body));
60
+ this.transactionId = null;
61
+ if (tags != null && tags !== '')
62
+ this.properties['TAGS'] = tags;
63
+ if (keys != null && keys !== '')
64
+ this.properties['KEYS'] = keys;
65
+ }
66
+ setTags(t) { this.properties['TAGS'] = t; }
67
+ getTags() { return this.properties['TAGS'] || null; }
68
+ setKeys(k) { this.properties['KEYS'] = k; }
69
+ getKeys() { return this.properties['KEYS'] || null; }
70
+ setDelayTimeLevel(level) { this.properties['DELAY'] = String(level); }
71
+ getDelayTimeLevel() { return this.properties['DELAY'] || null; }
72
+ setDelayTimeSec(sec) { this.properties['TIMER_DELAY_SEC'] = String(sec); }
73
+ getDelayTimeSec() { return this.properties['TIMER_DELAY_SEC'] || null; }
74
+ setDelayTimeMs(ms) { this.properties['TIMER_DELAY_MS'] = String(ms); }
75
+ getDelayTimeMs() { return this.properties['TIMER_DELAY_MS'] || null; }
76
+ setDeliverTimeMs(ms) { this.properties['TIMER_DELIVER_MS'] = String(ms); }
77
+ getDeliverTimeMs() { return this.properties['TIMER_DELIVER_MS'] || null; }
78
+ setWaitStoreMsgOK(ok) { this.properties['WAIT'] = ok ? 'true' : 'false'; }
79
+ getWaitStoreMsgOK() { return this.properties['WAIT'] || null; }
80
+ setUserProperty(name, value) { this.properties[name] = value; }
81
+ getUserProperty(name) { return this.properties[name] || null; }
82
+ putProperty(name, value) { this.properties[name] = value; }
83
+ getProperty(name) { return this.properties[name] || null; }
84
+ removeProperty(name) { delete this.properties[name]; }
85
+ clearProperty() { this.properties = {}; }
86
+ getTopic() { return this.topic; }
87
+ setTopic(t) { this.topic = t; }
88
+ getBody() { return this.body; }
89
+ setBody(b) { this.body = Buffer.isBuffer(b) ? b : Buffer.from(b); }
90
+ getFlag() { return this.flag; }
91
+ setFlag(f) { this.flag = f; }
92
+ getProperties() { return this.properties; }
93
+ setProperties(p) { this.properties = p || {}; }
94
+ getTransactionId() { return this.transactionId; }
95
+ setTransactionId(id) { this.transactionId = id; }
96
+ toString() { return `Message(topic='${this.topic}', body=${this.body.length} bytes)`; }
97
+ }
98
+ export class MessageExt extends Message {
99
+ queueId = 0;
100
+ storeSize = 0;
101
+ queueOffset = 0;
102
+ sysFlag = 0;
103
+ bornTimestamp = 0;
104
+ bornHost = null;
105
+ bornHostPort = 0;
106
+ storeTimestamp = 0;
107
+ storeHost = null;
108
+ storeHostPort = 0;
109
+ msgId = null;
110
+ commitLogOffset = 0;
111
+ bodyCrc = 0;
112
+ reconsumeTimes = 0;
113
+ preparedTransactionOffset = 0;
114
+ brokerName = null;
115
+ offsetMsgId = null;
116
+ msgType = null;
117
+ constructor(topic = '', body = null, tags = null, keys = null, flag = 0) {
118
+ super(topic, body, tags, keys, flag);
119
+ }
120
+ getQueueId() { return this.queueId; }
121
+ setQueueId(q) { this.queueId = q; }
122
+ getStoreSize() { return this.storeSize; }
123
+ setStoreSize(s) { this.storeSize = s; }
124
+ getQueueOffset() { return this.queueOffset; }
125
+ setQueueOffset(o) { this.queueOffset = o; }
126
+ getSysFlag() { return this.sysFlag; }
127
+ setSysFlag(f) { this.sysFlag = f; }
128
+ getBornTimestamp() { return this.bornTimestamp; }
129
+ setBornTimestamp(t) { this.bornTimestamp = t; }
130
+ getBornHost() { return this.bornHost; }
131
+ setBornHost(h) { this.bornHost = h; }
132
+ getStoreTimestamp() { return this.storeTimestamp; }
133
+ setStoreTimestamp(t) { this.storeTimestamp = t; }
134
+ getStoreHost() { return this.storeHost; }
135
+ setStoreHost(h) { this.storeHost = h; }
136
+ getMsgId() { return this.msgId; }
137
+ setMsgId(id) { this.msgId = id; }
138
+ getCommitLogOffset() { return this.commitLogOffset; }
139
+ setCommitLogOffset(o) { this.commitLogOffset = o; }
140
+ getBodyCrc() { return this.bodyCrc; }
141
+ setBodyCrc(c) { this.bodyCrc = c; }
142
+ getReconsumeTimes() { return this.reconsumeTimes; }
143
+ setReconsumeTimes(n) { this.reconsumeTimes = n; }
144
+ getPreparedTransactionOffset() { return this.preparedTransactionOffset; }
145
+ setPreparedTransactionOffset(o) { this.preparedTransactionOffset = o; }
146
+ setBrokerName(b) { this.brokerName = b; }
147
+ getBrokerName() { return this.brokerName; }
148
+ getOffsetMsgId() { return this.offsetMsgId; }
149
+ setOffsetMsgId(id) { this.offsetMsgId = id; }
150
+ getMsgType() { return this.msgType; }
151
+ setMsgType(t) { this.msgType = t; }
152
+ getBornHostString() { return (this.bornHost && this.bornHostPort) ? `${this.bornHost}:${this.bornHostPort}` : this.bornHost; }
153
+ getStoreHostString() { return (this.storeHost && this.storeHostPort) ? `${this.storeHost}:${this.storeHostPort}` : this.storeHost; }
154
+ toString() { return `MessageExt(topic='${this.topic}', msgId='${this.msgId}', queueOffset=${this.queueOffset}, body=${this.body.length} bytes)`; }
155
+ }
156
+ // A member asking to be delivered later — the delay level or any of the three timer
157
+ // spellings (relative seconds, relative milliseconds, absolute deliver-at). A batch
158
+ // leaves as ONE message with ONE property set, so such a request would land on the
159
+ // envelope carrying every other member; the whole batch is refused instead.
160
+ function scheduledDeliveryRequested(msg) {
161
+ const raws = [msg.getDelayTimeLevel(), msg.getDelayTimeSec(), msg.getDelayTimeMs(), msg.getDeliverTimeMs()];
162
+ for (const raw of raws) {
163
+ const value = raw ? parseInt(raw, 10) : 0;
164
+ if (!Number.isNaN(value) && value > 0)
165
+ return true;
166
+ }
167
+ return false;
168
+ }
169
+ export class MessageBatch extends Message {
170
+ messages;
171
+ constructor(messages = null) {
172
+ super();
173
+ this.messages = messages ? Array.from(messages) : [];
174
+ if (this.messages.length > 0) {
175
+ const first = this.messages[0];
176
+ this.setTopic(first.getTopic());
177
+ this.setWaitStoreMsgOK(first.getWaitStoreMsgOK());
178
+ // The on-wire batch body is just each message's 17-field format concatenated end to end;
179
+ // if this is not written back, send() will report "the message body length is zero" at
180
+ // Validators.checkMessage (generateFromList hits exactly this line).
181
+ this.setBody(encodeMessages(this.messages));
182
+ }
183
+ }
184
+ encode() { return encodeMessages(this.messages); }
185
+ [Symbol.iterator]() { return this.messages[Symbol.iterator](); }
186
+ get length() { return this.messages.length; }
187
+ static generateFromList(messages) {
188
+ if (!messages || messages.length === 0)
189
+ throw new Error('messages must not be null or empty');
190
+ const list = [];
191
+ let first = null;
192
+ for (const m of messages) {
193
+ if (scheduledDeliveryRequested(m))
194
+ throw new Error('Delayed messages are not supported for batching');
195
+ if ((m.getTopic() || '').startsWith('%RETRY%'))
196
+ throw new Error('Retry Group is not supported for batching');
197
+ if (first == null)
198
+ first = m;
199
+ else {
200
+ if (first.getTopic() !== m.getTopic())
201
+ throw new Error('The topic of the messages in one batch should be the same');
202
+ if (first.getWaitStoreMsgOK() !== m.getWaitStoreMsgOK())
203
+ throw new Error('The waitStoreMsgOK of the messages in one batch should be the same');
204
+ }
205
+ list.push(m);
206
+ }
207
+ const batch = new MessageBatch(list);
208
+ batch.setTopic(first.getTopic());
209
+ batch.setWaitStoreMsgOK(isWaitStoreMsgOK(first));
210
+ batch.setBody(encodeMessages(list));
211
+ return batch;
212
+ }
213
+ }
214
+ export default { MessageQueue, Message, MessageExt, MessageBatch, isWaitStoreMsgOK };
@@ -0,0 +1,7 @@
1
+ export declare function createUniqID(): string;
2
+ export declare function clientMsgId(msg: any): string | null;
3
+ declare const _default: {
4
+ createUniqID: typeof createUniqID;
5
+ clientMsgId: typeof clientMsgId;
6
+ };
7
+ export default _default;
@@ -0,0 +1,48 @@
1
+ import { getHostIp, getPid, bytes2string } from "./utilAll.js";
2
+ import { MessageConst } from "./messageConst.js";
3
+ function ipToBytes(ip) {
4
+ const parts = ip.split('.').map(Number);
5
+ const b = Buffer.alloc(4);
6
+ b.writeUInt8(parts[0] | 0, 0);
7
+ b.writeUInt8(parts[1] | 0, 1);
8
+ b.writeUInt8(parts[2] | 0, 2);
9
+ b.writeUInt8(parts[3] | 0, 3);
10
+ return b;
11
+ }
12
+ // The id is 16 raw bytes rendered as 32 uppercase hex chars:
13
+ // IP (4) + pid (2) + class hash (4) + millis into the month (4) + counter (2).
14
+ const IP = ipToBytes(getHostIp());
15
+ const PID = Buffer.alloc(2);
16
+ PID.writeUInt16BE(getPid() & 0xffff, 0);
17
+ const CLASS_HASH = Buffer.alloc(4); // reserved slot, always 0
18
+ // Start instant of the elapsed-millis field: local start of the month this
19
+ // process was launched in.
20
+ function monthStartMillis(now) {
21
+ const d = new Date(now);
22
+ return new Date(d.getFullYear(), d.getMonth(), 1, 0, 0, 0, 0).getTime();
23
+ }
24
+ const START_TIME = monthStartMillis(Date.now());
25
+ const COUNTER = { value: 0 };
26
+ const COUNTER_MAX = 0xffff;
27
+ export function createUniqID() {
28
+ COUNTER.value = (COUNTER.value + 1) & COUNTER_MAX;
29
+ const elapsed = Buffer.alloc(4);
30
+ elapsed.writeUInt32BE((Date.now() - START_TIME) >>> 0, 0);
31
+ const counter = Buffer.alloc(2);
32
+ counter.writeUInt16BE(COUNTER.value, 0);
33
+ return bytes2string(Buffer.concat([IP, PID, CLASS_HASH, elapsed, counter]));
34
+ }
35
+ // Java MessageClientExt.getMsgId() parity on a consumed message.
36
+ //
37
+ // Client-side decoding (decodesBatch(..., isClient=true)) keeps the broker offset
38
+ // id in msg.msgId / msg.offsetMsgId and exposes UNIQ_KEY as a normal property.
39
+ // Java's getMsgId() returns UNIQ_KEY and only falls back to the offset id when
40
+ // that property is absent, so every place that in Java calls msg.getMsgId() on
41
+ // a *consumed* message must go through this helper instead of reading the
42
+ // offset id directly.
43
+ export function clientMsgId(msg) {
44
+ if (msg == null)
45
+ return null;
46
+ return msg.getProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX) || msg.getMsgId();
47
+ }
48
+ export default { createUniqID, clientMsgId };
@@ -0,0 +1,68 @@
1
+ export declare const MessageConst: {
2
+ PROPERTY_KEYS: string;
3
+ PROPERTY_TAGS: string;
4
+ PROPERTY_WAIT_STORE_MSG_OK: string;
5
+ PROPERTY_DELAY_TIME_LEVEL: string;
6
+ PROPERTY_RETRY_TOPIC: string;
7
+ PROPERTY_REAL_TOPIC: string;
8
+ PROPERTY_REAL_QUEUE_ID: string;
9
+ PROPERTY_TRANSACTION_PREPARED: string;
10
+ PROPERTY_PRODUCER_GROUP: string;
11
+ PROPERTY_MIN_OFFSET: string;
12
+ PROPERTY_MAX_OFFSET: string;
13
+ PROPERTY_BUYER_ID: string;
14
+ PROPERTY_ORIGIN_MESSAGE_ID: string;
15
+ PROPERTY_TRANSFER_FLAG: string;
16
+ PROPERTY_CHECK_IMMUNITY_TIME_IN_SECONDS: string;
17
+ PROPERTY_RECONSUME_TIME: string;
18
+ PROPERTY_MSG_REGION: string;
19
+ PROPERTY_TRACE_SWITCH: string;
20
+ PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX: string;
21
+ PROPERTY_MAX_RECONSUME_TIMES: string;
22
+ PROPERTY_CONSUME_START_TIMESTAMP: string;
23
+ PROPERTY_TRANSACTION_PREPARED_QUEUE_OFFSET: string;
24
+ PROPERTY_TRANSACTION_CHECK_TIMES: string;
25
+ PROPERTY_CHECKED_TOPIC: string;
26
+ PROPERTY_BORN_HOST: string;
27
+ PROPERTY_BORN_TIMESTAMP: string;
28
+ PROPERTY_STORE_HOST: string;
29
+ PROPERTY_STORE_TIMESTAMP: string;
30
+ PROPERTY_MSG_ID: string;
31
+ PROPERTY_WAIT_STORE_MSG_OK_PROP: string;
32
+ PROPERTY_INSTANCE_ID: string;
33
+ PROPERTY_CLUSTER: string;
34
+ PROPERTY_MESSAGE_TYPE: string;
35
+ PROPERTY_CORRELATION_ID: string;
36
+ PROPERTY_MESSAGE_REPLY_TO_CLIENT: string;
37
+ PROPERTY_MESSAGE_TTL: string;
38
+ PROPERTY_REPLY_MESSAGE_ARRIVE_TIME: string;
39
+ PROPERTY_PUSH_REPLY_TIME: string;
40
+ PROPERTY_INNER_MULTI_DISPATCH: string;
41
+ PROPERTY_INNER_MULTI_QUEUE_OFFSET: string;
42
+ PROPERTY_POP_CK: string;
43
+ PROPERTY_POP_CK_OFFSET: string;
44
+ PROPERTY_POP_TIME: string;
45
+ PROPERTY_FIRST_POP_TIME: string;
46
+ PROPERTY_INVISIBLE_TIME: string;
47
+ PROPERTY_START_TIME: string;
48
+ PROPERTY_END_TIME: string;
49
+ PROPERTY_EXPIRE_TIME: string;
50
+ PROPERTY_LAST_CONSUME_TIMESTAMP: string;
51
+ PROPERTY_SELF_CONSUME_ENABLE: string;
52
+ PROPERTY_RECONSUME_GROUP: string;
53
+ PROPERTY_RECONSUME_TOPIC: string;
54
+ PROPERTY_KEYS_CONST: string;
55
+ PROPERTY_ORIGIN_QUEUE_ID: string;
56
+ PROPERTY_ORIGIN_TOPIC: string;
57
+ PROPERTY_TIMER_DELIVER_MS: string;
58
+ PROPERTY_TIMER_DELAY_SEC: string;
59
+ PROPERTY_TIMER_DELAY_MS: string;
60
+ PROPERTY_TRACE_PARENT: string;
61
+ KEY_SEPARATOR: string;
62
+ CHARACTER_MAX_LENGTH: number;
63
+ MESSAGE_ID_PREFIX: string;
64
+ INDEX_KEY_TYPE: string;
65
+ INDEX_UNIQUE_TYPE: string;
66
+ INDEX_TAG_TYPE: string;
67
+ };
68
+ export default MessageConst;
@@ -0,0 +1,68 @@
1
+ export const MessageConst = {
2
+ PROPERTY_KEYS: 'KEYS',
3
+ PROPERTY_TAGS: 'TAGS',
4
+ PROPERTY_WAIT_STORE_MSG_OK: 'WAIT',
5
+ PROPERTY_DELAY_TIME_LEVEL: 'DELAY',
6
+ PROPERTY_RETRY_TOPIC: 'RETRY_TOPIC',
7
+ PROPERTY_REAL_TOPIC: 'REAL_TOPIC',
8
+ PROPERTY_REAL_QUEUE_ID: 'REAL_QID',
9
+ PROPERTY_TRANSACTION_PREPARED: 'TRAN_MSG',
10
+ PROPERTY_PRODUCER_GROUP: 'PGROUP',
11
+ PROPERTY_MIN_OFFSET: 'MIN_OFFSET',
12
+ PROPERTY_MAX_OFFSET: 'MAX_OFFSET',
13
+ PROPERTY_BUYER_ID: 'BUYER_ID',
14
+ PROPERTY_ORIGIN_MESSAGE_ID: 'ORIGIN_MESSAGE_ID',
15
+ PROPERTY_TRANSFER_FLAG: 'TRANSFER_FLAG',
16
+ PROPERTY_CHECK_IMMUNITY_TIME_IN_SECONDS: 'CHECK_IMMUNITY_TIME_IN_SECONDS',
17
+ PROPERTY_RECONSUME_TIME: 'RECONSUME_TIME',
18
+ PROPERTY_MSG_REGION: 'MSG_REGION',
19
+ PROPERTY_TRACE_SWITCH: 'TRACE_ON',
20
+ PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX: 'UNIQ_KEY',
21
+ PROPERTY_MAX_RECONSUME_TIMES: 'MAX_RECONSUME_TIMES',
22
+ PROPERTY_CONSUME_START_TIMESTAMP: 'CONSUME_START_TIME',
23
+ PROPERTY_TRANSACTION_PREPARED_QUEUE_OFFSET: 'TRAN_PREPARED_QUEUE_OFFSET',
24
+ PROPERTY_TRANSACTION_CHECK_TIMES: 'TRANSACTION_CHECK_TIMES',
25
+ PROPERTY_CHECKED_TOPIC: 'CHECKED_TOPIC',
26
+ PROPERTY_BORN_HOST: 'BORN_HOST',
27
+ PROPERTY_BORN_TIMESTAMP: 'BORN_TIMESTAMP',
28
+ PROPERTY_STORE_HOST: 'STORE_HOST',
29
+ PROPERTY_STORE_TIMESTAMP: 'STORE_TIMESTAMP',
30
+ PROPERTY_MSG_ID: 'MSG_ID',
31
+ PROPERTY_WAIT_STORE_MSG_OK_PROP: 'WAIT_STORE_MSG_OK',
32
+ PROPERTY_INSTANCE_ID: 'INSTANCE_ID',
33
+ PROPERTY_CLUSTER: 'CLUSTER',
34
+ PROPERTY_MESSAGE_TYPE: 'MSG_TYPE',
35
+ PROPERTY_CORRELATION_ID: 'CORRELATION_ID',
36
+ PROPERTY_MESSAGE_REPLY_TO_CLIENT: 'REPLY_TO_CLIENT',
37
+ PROPERTY_MESSAGE_TTL: 'TTL',
38
+ PROPERTY_REPLY_MESSAGE_ARRIVE_TIME: 'REPLY_MESSAGE_ARRIVE_TIME',
39
+ PROPERTY_PUSH_REPLY_TIME: 'PUSH_REPLY_TIME',
40
+ PROPERTY_INNER_MULTI_DISPATCH: 'INNER_MULTI_DISPATCH',
41
+ PROPERTY_INNER_MULTI_QUEUE_OFFSET: 'INNER_MULTI_QUEUE_OFFSET',
42
+ PROPERTY_POP_CK: 'POP_CK',
43
+ PROPERTY_POP_CK_OFFSET: 'POP_CK_OFFSET',
44
+ PROPERTY_POP_TIME: 'POP_TIME',
45
+ PROPERTY_FIRST_POP_TIME: '1ST_POP_TIME',
46
+ PROPERTY_INVISIBLE_TIME: 'INVISIBLE_TIME',
47
+ PROPERTY_START_TIME: 'START_TIME',
48
+ PROPERTY_END_TIME: 'END_TIME',
49
+ PROPERTY_EXPIRE_TIME: 'EXPIRE_TIME',
50
+ PROPERTY_LAST_CONSUME_TIMESTAMP: 'LAST_CONSUME_TIME',
51
+ PROPERTY_SELF_CONSUME_ENABLE: 'SELF_CONSUME',
52
+ PROPERTY_RECONSUME_GROUP: 'RECONSUME_GROUP',
53
+ PROPERTY_RECONSUME_TOPIC: 'RECONSUME_TOPIC',
54
+ PROPERTY_KEYS_CONST: 'KEYS',
55
+ PROPERTY_ORIGIN_QUEUE_ID: 'ORIGIN_QID',
56
+ PROPERTY_ORIGIN_TOPIC: 'ORIGIN_TOPIC',
57
+ PROPERTY_TIMER_DELIVER_MS: 'TIMER_DELIVER_MS',
58
+ PROPERTY_TIMER_DELAY_SEC: 'TIMER_DELAY_SEC',
59
+ PROPERTY_TIMER_DELAY_MS: 'TIMER_DELAY_MS',
60
+ PROPERTY_TRACE_PARENT: 'traceparent',
61
+ KEY_SEPARATOR: ' ',
62
+ CHARACTER_MAX_LENGTH: 255,
63
+ MESSAGE_ID_PREFIX: 'MSGID-',
64
+ INDEX_KEY_TYPE: 'K',
65
+ INDEX_UNIQUE_TYPE: 'U',
66
+ INDEX_TAG_TYPE: 'T',
67
+ };
68
+ export default MessageConst;
@@ -0,0 +1,40 @@
1
+ import { Buffer } from 'node:buffer';
2
+ import { Message, MessageExt } from './message.js';
3
+ export declare function createMessageId(addrBytes: Buffer, offset: number): string;
4
+ export declare function decodeMessageId(msgId: string): {
5
+ ip: string;
6
+ port: number;
7
+ offset: number;
8
+ };
9
+ export declare function messageProperties2String(properties?: Record<string, string> | null): string;
10
+ export declare function string2MessageProperties(propertiesStr?: string | null): Record<string, string>;
11
+ export declare function decompressBody(data: Buffer, compressionType: number): Buffer;
12
+ export declare function encodeMessageExt(messageExt: MessageExt, needCompress?: boolean): Buffer;
13
+ export declare function decodeMessage(raw: Buffer, readBody?: boolean, decompressBody?: boolean, isClient?: boolean, checkCrc?: boolean): MessageExt | null;
14
+ export declare function decodeMessages(raw: Buffer, readBody?: boolean): MessageExt[];
15
+ export declare function encodeMessage(message: Message): Buffer;
16
+ export declare function encodeMessages(messages: Message[]): Buffer;
17
+ declare function decodeBatchMessage(raw: Buffer): Message;
18
+ export declare function decodeBatchMessages(raw: Buffer): Message[];
19
+ export declare function decodeInnerBatchMessages(msgs: MessageExt[]): MessageExt[];
20
+ export declare function countInnerMsgNum(raw: Buffer): number;
21
+ declare const _default: {
22
+ MESSAGE_MAGIC_CODE: number;
23
+ MESSAGE_MAGIC_CODE_V2: number;
24
+ BLANK_MAGIC_CODE: number;
25
+ createMessageId: typeof createMessageId;
26
+ decodeMessageId: typeof decodeMessageId;
27
+ messageProperties2String: typeof messageProperties2String;
28
+ string2MessageProperties: typeof string2MessageProperties;
29
+ encodeMessageExt: typeof encodeMessageExt;
30
+ decodeMessage: typeof decodeMessage;
31
+ decodeMessages: typeof decodeMessages;
32
+ encodeMessage: typeof encodeMessage;
33
+ encodeMessages: typeof encodeMessages;
34
+ decodeBatchMessage: typeof decodeBatchMessage;
35
+ decodeBatchMessages: typeof decodeBatchMessages;
36
+ decodeInnerBatchMessages: typeof decodeInnerBatchMessages;
37
+ countInnerMsgNum: typeof countInnerMsgNum;
38
+ decompressBody: typeof decompressBody;
39
+ };
40
+ export default _default;