rocketmq-client-nodejs 1.0.2 → 1.0.5
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.
- package/README.md +84 -1
- package/dist/client/BaseClient.d.ts +24 -2
- package/dist/client/BaseClient.js +173 -28
- package/dist/client/ClientId.js +2 -2
- package/dist/client/Logger.d.ts +1 -0
- package/dist/client/Logger.js +1 -1
- package/dist/client/RpcClient.d.ts +3 -1
- package/dist/client/RpcClient.js +23 -1
- package/dist/client/RpcClientManager.d.ts +3 -1
- package/dist/client/RpcClientManager.js +23 -4
- package/dist/client/TelemetrySession.d.ts +1 -0
- package/dist/client/TelemetrySession.js +47 -9
- package/dist/consumer/Assignment.d.ts +24 -0
- package/dist/consumer/Assignment.js +40 -0
- package/dist/consumer/Assignments.d.ts +25 -0
- package/dist/consumer/Assignments.js +55 -0
- package/dist/consumer/ConsumeResult.d.ts +20 -0
- package/dist/consumer/ConsumeResult.js +25 -0
- package/dist/consumer/ConsumeService.d.ts +28 -0
- package/dist/consumer/ConsumeService.js +53 -0
- package/dist/consumer/ConsumeTask.d.ts +24 -0
- package/dist/consumer/ConsumeTask.js +39 -0
- package/dist/consumer/Consumer.d.ts +19 -1
- package/dist/consumer/Consumer.js +64 -21
- package/dist/consumer/FifoConsumeService.d.ts +25 -0
- package/dist/consumer/FifoConsumeService.js +130 -0
- package/dist/consumer/FilterExpression.d.ts +2 -0
- package/dist/consumer/FilterExpression.js +18 -1
- package/dist/consumer/LitePushConsumer.d.ts +161 -0
- package/dist/consumer/LitePushConsumer.js +172 -0
- package/dist/consumer/LitePushConsumerImpl.d.ts +167 -0
- package/dist/consumer/LitePushConsumerImpl.js +193 -0
- package/dist/consumer/LiteSubscriptionManager.d.ts +97 -0
- package/dist/consumer/LiteSubscriptionManager.js +236 -0
- package/dist/consumer/MessageListener.d.ts +21 -0
- package/dist/consumer/MessageListener.js +19 -0
- package/dist/consumer/OffsetOption.d.ts +109 -0
- package/dist/consumer/OffsetOption.js +191 -0
- package/dist/consumer/ProcessQueue.d.ts +39 -0
- package/dist/consumer/ProcessQueue.js +293 -0
- package/dist/consumer/PushConsumer.d.ts +88 -0
- package/dist/consumer/PushConsumer.js +449 -0
- package/dist/consumer/PushSubscriptionSettings.d.ts +31 -0
- package/dist/consumer/PushSubscriptionSettings.js +97 -0
- package/dist/consumer/SimpleConsumer.d.ts +12 -1
- package/dist/consumer/SimpleConsumer.js +54 -10
- package/dist/consumer/SimpleSubscriptionSettings.d.ts +2 -2
- package/dist/consumer/SimpleSubscriptionSettings.js +3 -3
- package/dist/consumer/StandardConsumeService.d.ts +25 -0
- package/dist/consumer/StandardConsumeService.js +50 -0
- package/dist/consumer/index.d.ts +15 -0
- package/dist/consumer/index.js +19 -1
- package/dist/exception/InternalErrorException.d.ts +5 -0
- package/dist/exception/InternalErrorException.js +10 -1
- package/dist/exception/LiteSubscriptionQuotaExceededException.d.ts +23 -0
- package/dist/exception/LiteSubscriptionQuotaExceededException.js +31 -0
- package/dist/exception/LiteTopicQuotaExceededException.d.ts +23 -0
- package/dist/exception/LiteTopicQuotaExceededException.js +31 -0
- package/dist/exception/StatusChecker.js +4 -1
- package/dist/exception/index.d.ts +2 -0
- package/dist/exception/index.js +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/message/Message.d.ts +8 -0
- package/dist/message/Message.js +39 -6
- package/dist/message/MessageId.d.ts +2 -0
- package/dist/message/MessageId.js +17 -1
- package/dist/message/MessageView.d.ts +86 -0
- package/dist/message/MessageView.js +115 -1
- package/dist/message/PublishingMessage.js +21 -5
- package/dist/producer/Producer.d.ts +21 -2
- package/dist/producer/Producer.js +120 -25
- package/dist/producer/PublishingLoadBalancer.d.ts +2 -0
- package/dist/producer/PublishingLoadBalancer.js +23 -1
- package/dist/producer/RecallReceipt.d.ts +25 -0
- package/dist/producer/RecallReceipt.js +34 -0
- package/dist/producer/SendReceipt.d.ts +2 -1
- package/dist/producer/SendReceipt.js +6 -3
- package/dist/producer/Transaction.js +7 -1
- package/dist/producer/index.d.ts +1 -0
- package/dist/producer/index.js +2 -1
- package/dist/route/Broker.d.ts +2 -0
- package/dist/route/Broker.js +21 -1
- package/dist/route/Endpoints.d.ts +2 -0
- package/dist/route/Endpoints.js +36 -1
- package/dist/route/MessageQueue.d.ts +2 -0
- package/dist/route/MessageQueue.js +23 -1
- package/dist/route/Resource.d.ts +54 -0
- package/dist/route/Resource.js +100 -0
- package/dist/route/TopicRouteData.d.ts +12 -0
- package/dist/route/TopicRouteData.js +37 -1
- package/dist/route/index.d.ts +1 -0
- package/dist/route/index.js +2 -1
- package/dist/util/index.d.ts +8 -0
- package/dist/util/index.js +20 -1
- package/package.json +2 -3
- package/proto/apache/rocketmq/v2/definition.proto +56 -0
- package/proto/apache/rocketmq/v2/definition_pb.d.ts +100 -0
- package/proto/apache/rocketmq/v2/definition_pb.js +570 -4
- package/proto/apache/rocketmq/v2/service.proto +65 -0
- package/proto/apache/rocketmq/v2/service_grpc_pb.d.ts +34 -0
- package/proto/apache/rocketmq/v2/service_grpc_pb.js +81 -4
- package/proto/apache/rocketmq/v2/service_pb.d.ts +211 -0
- package/proto/apache/rocketmq/v2/service_pb.js +1691 -25
- package/src/client/BaseClient.ts +196 -28
- package/src/client/ClientId.ts +1 -1
- package/src/client/Logger.ts +1 -0
- package/src/client/RpcClient.ts +26 -0
- package/src/client/RpcClientManager.ts +27 -3
- package/src/client/TelemetrySession.ts +54 -8
- package/src/consumer/Assignment.ts +40 -0
- package/src/consumer/Assignments.ts +55 -0
- package/src/consumer/ConsumeResult.ts +21 -0
- package/src/consumer/ConsumeService.ts +72 -0
- package/src/consumer/ConsumeTask.ts +39 -0
- package/src/consumer/Consumer.ts +76 -20
- package/src/consumer/FifoConsumeService.ts +146 -0
- package/src/consumer/FilterExpression.ts +17 -0
- package/src/consumer/LitePushConsumer.ts +256 -0
- package/src/consumer/LitePushConsumerImpl.ts +245 -0
- package/src/consumer/LiteSubscriptionManager.ts +352 -0
- package/src/consumer/MessageListener.ts +23 -0
- package/src/consumer/OffsetOption.ts +203 -0
- package/src/consumer/ProcessQueue.ts +339 -0
- package/src/consumer/PushConsumer.ts +563 -0
- package/src/consumer/PushSubscriptionSettings.ts +124 -0
- package/src/consumer/SimpleConsumer.ts +68 -11
- package/src/consumer/SimpleSubscriptionSettings.ts +2 -2
- package/src/consumer/StandardConsumeService.ts +57 -0
- package/src/consumer/index.ts +15 -0
- package/src/exception/InternalErrorException.ts +10 -0
- package/src/exception/LiteSubscriptionQuotaExceededException.ts +28 -0
- package/src/exception/LiteTopicQuotaExceededException.ts +28 -0
- package/src/exception/StatusChecker.ts +3 -0
- package/src/exception/index.ts +2 -0
- package/src/index.ts +1 -0
- package/src/message/Message.ts +46 -5
- package/src/message/MessageId.ts +16 -0
- package/src/message/MessageView.ts +127 -0
- package/src/message/PublishingMessage.ts +20 -4
- package/src/producer/Producer.ts +144 -24
- package/src/producer/PublishingLoadBalancer.ts +21 -0
- package/src/producer/RecallReceipt.ts +32 -0
- package/src/producer/SendReceipt.ts +5 -2
- package/src/producer/Transaction.ts +16 -0
- package/src/producer/index.ts +1 -0
- package/src/route/Broker.ts +20 -0
- package/src/route/Endpoints.ts +32 -0
- package/src/route/MessageQueue.ts +23 -1
- package/src/route/Resource.ts +104 -0
- package/src/route/TopicRouteData.ts +37 -0
- package/src/route/index.ts +1 -0
- package/src/util/index.ts +19 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
4
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
5
|
+
* this work for additional information regarding copyright ownership.
|
|
6
|
+
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
7
|
+
* (the "License"); you may not use this file except in compliance with
|
|
8
|
+
* the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.LitePushConsumerBuilder = void 0;
|
|
20
|
+
const LitePushConsumerImpl_1 = require("./LitePushConsumerImpl");
|
|
21
|
+
const CONSUMER_GROUP_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
22
|
+
/**
|
|
23
|
+
* LitePushConsumer builder class.
|
|
24
|
+
*
|
|
25
|
+
* <p>This class provides a fluent API for configuring and creating
|
|
26
|
+
* lite push consumers with reduced overhead for lightweight scenarios.</p>
|
|
27
|
+
*/
|
|
28
|
+
class LitePushConsumerBuilder {
|
|
29
|
+
options = {};
|
|
30
|
+
/**
|
|
31
|
+
* Set the bind topic for the lite push consumer.
|
|
32
|
+
*
|
|
33
|
+
* @param bindTopic - The parent topic to bind
|
|
34
|
+
* @return This builder instance
|
|
35
|
+
* @throws Error if bindTopic is blank
|
|
36
|
+
*/
|
|
37
|
+
bindTopic(bindTopic) {
|
|
38
|
+
if (!bindTopic || bindTopic.trim().length === 0) {
|
|
39
|
+
throw new Error('bindTopic should not be blank');
|
|
40
|
+
}
|
|
41
|
+
this.options.bindTopic = bindTopic;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Set the client configuration.
|
|
46
|
+
*
|
|
47
|
+
* @param options - Client configuration options
|
|
48
|
+
* @return This builder instance
|
|
49
|
+
* @throws Error if options is null/undefined
|
|
50
|
+
*/
|
|
51
|
+
setClientConfiguration(options) {
|
|
52
|
+
if (!options) {
|
|
53
|
+
throw new Error('clientConfiguration should not be null');
|
|
54
|
+
}
|
|
55
|
+
Object.assign(this.options, options);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Set the consumer group.
|
|
60
|
+
*
|
|
61
|
+
* @param consumerGroup - Consumer group name
|
|
62
|
+
* @return This builder instance
|
|
63
|
+
* @throws Error if consumerGroup is null, doesn't match the pattern, or starts with 'GID-'
|
|
64
|
+
*/
|
|
65
|
+
setConsumerGroup(consumerGroup) {
|
|
66
|
+
if (!consumerGroup) {
|
|
67
|
+
throw new Error('consumerGroup should not be null');
|
|
68
|
+
}
|
|
69
|
+
if (!CONSUMER_GROUP_PATTERN.test(consumerGroup)) {
|
|
70
|
+
throw new Error(`consumerGroup does not match the pattern ${CONSUMER_GROUP_PATTERN.source}`);
|
|
71
|
+
}
|
|
72
|
+
this.options.consumerGroup = consumerGroup;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Set the message listener.
|
|
77
|
+
*
|
|
78
|
+
* @param messageListener - Message listener implementation
|
|
79
|
+
* @return This builder instance
|
|
80
|
+
* @throws Error if messageListener is null/undefined
|
|
81
|
+
*/
|
|
82
|
+
setMessageListener(messageListener) {
|
|
83
|
+
if (!messageListener) {
|
|
84
|
+
throw new Error('messageListener should not be null');
|
|
85
|
+
}
|
|
86
|
+
this.options.messageListener = messageListener;
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Set the maximum cache message count.
|
|
91
|
+
*
|
|
92
|
+
* @param maxCacheMessageCount - Maximum number of messages to cache
|
|
93
|
+
* @return This builder instance
|
|
94
|
+
* @throws Error if maxCacheMessageCount is not positive
|
|
95
|
+
*/
|
|
96
|
+
setMaxCacheMessageCount(maxCacheMessageCount) {
|
|
97
|
+
if (maxCacheMessageCount <= 0) {
|
|
98
|
+
throw new Error('maxCacheMessageCount should be positive');
|
|
99
|
+
}
|
|
100
|
+
// TODO: Will be used when implementing full consumer
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Set the maximum cache message size in bytes.
|
|
105
|
+
*
|
|
106
|
+
* @param maxCacheMessageSizeInBytes - Maximum cache size in bytes
|
|
107
|
+
* @return This builder instance
|
|
108
|
+
* @throws Error if maxCacheMessageSizeInBytes is not positive
|
|
109
|
+
*/
|
|
110
|
+
setMaxCacheMessageSizeInBytes(maxCacheMessageSizeInBytes) {
|
|
111
|
+
if (maxCacheMessageSizeInBytes <= 0) {
|
|
112
|
+
throw new Error('maxCacheMessageSizeInBytes should be positive');
|
|
113
|
+
}
|
|
114
|
+
// TODO: Will be used when implementing full consumer
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Set the consumption thread count.
|
|
119
|
+
*
|
|
120
|
+
* @param consumptionThreadCount - Number of threads for consumption
|
|
121
|
+
* @return This builder instance
|
|
122
|
+
* @throws Error if consumptionThreadCount is not positive
|
|
123
|
+
*/
|
|
124
|
+
setConsumptionThreadCount(consumptionThreadCount) {
|
|
125
|
+
if (consumptionThreadCount <= 0) {
|
|
126
|
+
throw new Error('consumptionThreadCount should be positive');
|
|
127
|
+
}
|
|
128
|
+
// TODO: Will be used when implementing full consumer
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Finalize the build of LitePushConsumer and start.
|
|
133
|
+
*
|
|
134
|
+
* <p>This method will block until the push consumer starts successfully.
|
|
135
|
+
*
|
|
136
|
+
* <p>Especially, if this method is invoked more than once, different push consumers will be created and started.
|
|
137
|
+
*
|
|
138
|
+
* @return Promise resolving to started LitePushConsumer instance
|
|
139
|
+
* @throws Error if required parameters are not set
|
|
140
|
+
*/
|
|
141
|
+
async build() {
|
|
142
|
+
if (!this.options.endpoints) {
|
|
143
|
+
throw new Error('clientConfiguration has not been set yet');
|
|
144
|
+
}
|
|
145
|
+
if (!this.options.consumerGroup) {
|
|
146
|
+
throw new Error('consumerGroup has not been set yet');
|
|
147
|
+
}
|
|
148
|
+
if (!this.options.messageListener) {
|
|
149
|
+
throw new Error('messageListener has not been set yet');
|
|
150
|
+
}
|
|
151
|
+
if (!this.options.bindTopic) {
|
|
152
|
+
throw new Error('bindTopic has not been set yet');
|
|
153
|
+
}
|
|
154
|
+
// Build LitePushConsumerImpl
|
|
155
|
+
const options = {
|
|
156
|
+
endpoints: this.options.endpoints,
|
|
157
|
+
namespace: this.options.namespace ?? '',
|
|
158
|
+
consumerGroup: this.options.consumerGroup,
|
|
159
|
+
bindTopic: this.options.bindTopic,
|
|
160
|
+
messageListener: this.options.messageListener,
|
|
161
|
+
sslEnabled: this.options.sslEnabled,
|
|
162
|
+
sessionCredentials: this.options.sessionCredentials,
|
|
163
|
+
requestTimeout: this.options.requestTimeout,
|
|
164
|
+
logger: this.options.logger,
|
|
165
|
+
};
|
|
166
|
+
const litePushConsumer = new LitePushConsumerImpl_1.LitePushConsumerImpl(options);
|
|
167
|
+
await litePushConsumer.startup();
|
|
168
|
+
return litePushConsumer;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
exports.LitePushConsumerBuilder = LitePushConsumerBuilder;
|
|
172
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTGl0ZVB1c2hDb25zdW1lci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb25zdW1lci9MaXRlUHVzaENvbnN1bWVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7OztBQUtILGlFQUE4RDtBQTJFOUQsTUFBTSxzQkFBc0IsR0FBRyxrQkFBa0IsQ0FBQztBQUVsRDs7Ozs7R0FLRztBQUNILE1BQWEsdUJBQXVCO0lBQzFCLE9BQU8sR0FBcUMsRUFBRSxDQUFDO0lBRXZEOzs7Ozs7T0FNRztJQUNILFNBQVMsQ0FBQyxTQUFpQjtRQUN6QixJQUFJLENBQUMsU0FBUyxJQUFJLFNB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ksMkNBQW9CLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDM0QsTUFBTSxnQkFBZ0IsQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUNqQyxPQUFPLGdCQUFnQixDQUFDO0lBQzFCLENBQUM7Q0FDRjtBQXhKRCwwREF3SkMifQ==
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright ownership.
|
|
5
|
+
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
6
|
+
* (the "License"); you may not use this file except in compliance with
|
|
7
|
+
* the License. You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { ClientType } from '../../proto/apache/rocketmq/v2/definition_pb';
|
|
18
|
+
import { NotifyUnsubscribeLiteCommand } from '../../proto/apache/rocketmq/v2/service_pb';
|
|
19
|
+
import { Endpoints, TopicRouteData } from '../route';
|
|
20
|
+
import { PushConsumer, PushConsumerOptions } from './PushConsumer';
|
|
21
|
+
import { LitePushConsumer } from './LitePushConsumer';
|
|
22
|
+
import { OffsetOption } from './OffsetOption';
|
|
23
|
+
export interface LitePushConsumerOptions extends PushConsumerOptions {
|
|
24
|
+
bindTopic: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Implementation of LitePushConsumer.
|
|
28
|
+
*
|
|
29
|
+
* <p>LitePushConsumer extends PushConsumer to provide lightweight message consumption
|
|
30
|
+
* with reduced metadata and storage overhead. It supports dynamic subscription
|
|
31
|
+
* management for lite topics.</p>
|
|
32
|
+
*
|
|
33
|
+
* <p>Key features:</p>
|
|
34
|
+
* <ul>
|
|
35
|
+
* <li>Dynamic lite topic subscription/unsubscription</li>
|
|
36
|
+
* <li>Quota management for lite subscriptions</li>
|
|
37
|
+
* <li>Reduced resource consumption compared to standard PushConsumer</li>
|
|
38
|
+
* <li>Automatic synchronization with server settings</li>
|
|
39
|
+
* </ul>
|
|
40
|
+
*
|
|
41
|
+
* <p>Note: Unlike LiteSimpleConsumer, LitePushConsumer does not perform route optimization
|
|
42
|
+
* because it uses the assignment-based message delivery mechanism managed by the server.</p>
|
|
43
|
+
*/
|
|
44
|
+
export declare class LitePushConsumerImpl extends PushConsumer implements LitePushConsumer {
|
|
45
|
+
private readonly liteSubscriptionManager;
|
|
46
|
+
private readonly bindTopic;
|
|
47
|
+
constructor(options: LitePushConsumerOptions);
|
|
48
|
+
/**
|
|
49
|
+
* Get the client type.
|
|
50
|
+
*
|
|
51
|
+
* @return The client type identifier for lite push consumer
|
|
52
|
+
*/
|
|
53
|
+
protected getClientType(): ClientType;
|
|
54
|
+
/**
|
|
55
|
+
* Override to disable standard assignment scanning for lite consumers.
|
|
56
|
+
* LitePushConsumer uses Lite Subscription mechanism instead of assignments.
|
|
57
|
+
*/
|
|
58
|
+
protected onTopicRouteDataUpdate(_topic: string, _topicRouteData: TopicRouteData): void;
|
|
59
|
+
/**
|
|
60
|
+
* Start up the consumer.
|
|
61
|
+
*
|
|
62
|
+
* <p>This method initializes the consumer and starts the lite subscription manager.
|
|
63
|
+
* It must be called before the consumer can receive messages.</p>
|
|
64
|
+
*/
|
|
65
|
+
startup(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Shutdown the consumer.
|
|
68
|
+
*
|
|
69
|
+
* <p>This method gracefully shuts down the consumer, releasing all resources
|
|
70
|
+
* and stopping the lite subscription manager.</p>
|
|
71
|
+
*/
|
|
72
|
+
shutdown(): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Subscribe to a lite topic.
|
|
75
|
+
*
|
|
76
|
+
* <p>The subscribeLite() method initiates network requests and performs quota verification,
|
|
77
|
+
* so it may fail. It's important to handle potential errors. Possible failure scenarios include:</p>
|
|
78
|
+
* <ul>
|
|
79
|
+
* <li>Network request errors, which can be retried.</li>
|
|
80
|
+
* <li>Quota verification failures (LiteSubscriptionQuotaExceededException).
|
|
81
|
+
* In this case, evaluate whether the quota is insufficient and promptly unsubscribe
|
|
82
|
+
* from unused subscriptions using unsubscribeLite() to free up resources.</li>
|
|
83
|
+
* </ul>
|
|
84
|
+
*
|
|
85
|
+
* @param liteTopic - The name of the lite topic to subscribe
|
|
86
|
+
*/
|
|
87
|
+
subscribeLite(liteTopic: string): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Subscribe to a lite topic with offset option to specify the consume from offset.
|
|
90
|
+
*
|
|
91
|
+
* @param liteTopic - The name of the lite topic to subscribe
|
|
92
|
+
* @param offsetOption - The consume from offset option
|
|
93
|
+
*/
|
|
94
|
+
subscribeLite(liteTopic: string, offsetOption: OffsetOption): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Unsubscribe from a lite topic.
|
|
97
|
+
*
|
|
98
|
+
* <p>This method removes the subscription and notifies the server.
|
|
99
|
+
* After unsubscribing, the consumer will no longer receive messages from this topic.</p>
|
|
100
|
+
*
|
|
101
|
+
* @param liteTopic - The name of the lite topic to unsubscribe from
|
|
102
|
+
*/
|
|
103
|
+
unsubscribeLite(liteTopic: string): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Get the lite topic set.
|
|
106
|
+
*
|
|
107
|
+
* <p>Returns an immutable set of currently subscribed lite topics.
|
|
108
|
+
* This set reflects the current state of subscriptions managed by the lite subscription manager.</p>
|
|
109
|
+
*
|
|
110
|
+
* @return Set of lite topic names
|
|
111
|
+
*/
|
|
112
|
+
getLiteTopicSet(): Set<string>;
|
|
113
|
+
/**
|
|
114
|
+
* Get the load balancing group for the consumer.
|
|
115
|
+
*
|
|
116
|
+
* <p>The consumer group is used for load balancing across multiple consumer instances.
|
|
117
|
+
* All consumers in the same group will share the message load.</p>
|
|
118
|
+
*
|
|
119
|
+
* @return Consumer group name
|
|
120
|
+
*/
|
|
121
|
+
getConsumerGroup(): string;
|
|
122
|
+
/**
|
|
123
|
+
* Handle notify unsubscribe lite command from server.
|
|
124
|
+
*
|
|
125
|
+
* <p>This method is called when the server sends a notification to unsubscribe
|
|
126
|
+
* from a lite topic, typically due to quota violations or administrative actions.</p>
|
|
127
|
+
*
|
|
128
|
+
* @param command - The unsubscribe command from the server
|
|
129
|
+
*/
|
|
130
|
+
onNotifyUnsubscribeLiteCommand(command: NotifyUnsubscribeLiteCommand): void;
|
|
131
|
+
/**
|
|
132
|
+
* Handle settings command from server.
|
|
133
|
+
*
|
|
134
|
+
* <p>This method processes configuration updates from the server and synchronizes
|
|
135
|
+
* the lite subscription manager with the latest settings.</p>
|
|
136
|
+
*
|
|
137
|
+
* @param endpoints - The server endpoints
|
|
138
|
+
* @param settings - The settings configuration
|
|
139
|
+
*/
|
|
140
|
+
onSettingsCommand(endpoints: any, settings: any): void;
|
|
141
|
+
/**
|
|
142
|
+
* Close the consumer.
|
|
143
|
+
*/
|
|
144
|
+
close(): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Get the logger.
|
|
147
|
+
*/
|
|
148
|
+
getLogger(): import("..").ILogger;
|
|
149
|
+
/**
|
|
150
|
+
* Get the RPC client manager (protected access for internal use).
|
|
151
|
+
*
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
getRpcClientManager(): import("..").RpcClientManager;
|
|
155
|
+
/**
|
|
156
|
+
* Get the endpoints (protected access for internal use).
|
|
157
|
+
*
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
getEndpoints(): Endpoints;
|
|
161
|
+
/**
|
|
162
|
+
* Get the request timeout (protected access for internal use).
|
|
163
|
+
*
|
|
164
|
+
* @internal
|
|
165
|
+
*/
|
|
166
|
+
getRequestTimeout(): number;
|
|
167
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
4
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
5
|
+
* this work for additional information regarding copyright ownership.
|
|
6
|
+
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
7
|
+
* (the "License"); you may not use this file except in compliance with
|
|
8
|
+
* the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.LitePushConsumerImpl = void 0;
|
|
20
|
+
const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
|
|
21
|
+
const Resource_1 = require("../route/Resource");
|
|
22
|
+
const PushConsumer_1 = require("./PushConsumer");
|
|
23
|
+
const LiteSubscriptionManager_1 = require("./LiteSubscriptionManager");
|
|
24
|
+
const FilterExpression_1 = require("./FilterExpression");
|
|
25
|
+
/**
|
|
26
|
+
* Implementation of LitePushConsumer.
|
|
27
|
+
*
|
|
28
|
+
* <p>LitePushConsumer extends PushConsumer to provide lightweight message consumption
|
|
29
|
+
* with reduced metadata and storage overhead. It supports dynamic subscription
|
|
30
|
+
* management for lite topics.</p>
|
|
31
|
+
*
|
|
32
|
+
* <p>Key features:</p>
|
|
33
|
+
* <ul>
|
|
34
|
+
* <li>Dynamic lite topic subscription/unsubscription</li>
|
|
35
|
+
* <li>Quota management for lite subscriptions</li>
|
|
36
|
+
* <li>Reduced resource consumption compared to standard PushConsumer</li>
|
|
37
|
+
* <li>Automatic synchronization with server settings</li>
|
|
38
|
+
* </ul>
|
|
39
|
+
*
|
|
40
|
+
* <p>Note: Unlike LiteSimpleConsumer, LitePushConsumer does not perform route optimization
|
|
41
|
+
* because it uses the assignment-based message delivery mechanism managed by the server.</p>
|
|
42
|
+
*/
|
|
43
|
+
class LitePushConsumerImpl extends PushConsumer_1.PushConsumer {
|
|
44
|
+
liteSubscriptionManager;
|
|
45
|
+
bindTopic;
|
|
46
|
+
constructor(options) {
|
|
47
|
+
// Create subscription expressions with bind topic
|
|
48
|
+
const subscriptions = new Map();
|
|
49
|
+
subscriptions.set(options.bindTopic, FilterExpression_1.FilterExpression.SUB_ALL);
|
|
50
|
+
super({
|
|
51
|
+
...options,
|
|
52
|
+
subscriptions,
|
|
53
|
+
});
|
|
54
|
+
this.bindTopic = new Resource_1.Resource(options.namespace, options.bindTopic);
|
|
55
|
+
const groupResource = new Resource_1.Resource(options.namespace, options.consumerGroup);
|
|
56
|
+
this.liteSubscriptionManager = new LiteSubscriptionManager_1.LiteSubscriptionManager(this, this.bindTopic, groupResource);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get the client type.
|
|
60
|
+
*
|
|
61
|
+
* @return The client type identifier for lite push consumer
|
|
62
|
+
*/
|
|
63
|
+
getClientType() {
|
|
64
|
+
return definition_pb_1.ClientType.LITE_PUSH_CONSUMER;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Override to disable standard assignment scanning for lite consumers.
|
|
68
|
+
* LitePushConsumer uses Lite Subscription mechanism instead of assignments.
|
|
69
|
+
*/
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
+
onTopicRouteDataUpdate(_topic, _topicRouteData) {
|
|
72
|
+
// Lite consumers do not use standard assignment mechanism
|
|
73
|
+
// They rely on LiteSubscriptionManager for message delivery
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Start up the consumer.
|
|
77
|
+
*
|
|
78
|
+
* <p>This method initializes the consumer and starts the lite subscription manager.
|
|
79
|
+
* It must be called before the consumer can receive messages.</p>
|
|
80
|
+
*/
|
|
81
|
+
async startup() {
|
|
82
|
+
await super.startup();
|
|
83
|
+
this.liteSubscriptionManager.startUp();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Shutdown the consumer.
|
|
87
|
+
*
|
|
88
|
+
* <p>This method gracefully shuts down the consumer, releasing all resources
|
|
89
|
+
* and stopping the lite subscription manager.</p>
|
|
90
|
+
*/
|
|
91
|
+
async shutdown() {
|
|
92
|
+
this.liteSubscriptionManager.shutdown();
|
|
93
|
+
await super.shutdown();
|
|
94
|
+
}
|
|
95
|
+
async subscribeLite(liteTopic, offsetOption) {
|
|
96
|
+
await this.liteSubscriptionManager.subscribeLite(liteTopic, offsetOption ?? null);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Unsubscribe from a lite topic.
|
|
100
|
+
*
|
|
101
|
+
* <p>This method removes the subscription and notifies the server.
|
|
102
|
+
* After unsubscribing, the consumer will no longer receive messages from this topic.</p>
|
|
103
|
+
*
|
|
104
|
+
* @param liteTopic - The name of the lite topic to unsubscribe from
|
|
105
|
+
*/
|
|
106
|
+
async unsubscribeLite(liteTopic) {
|
|
107
|
+
await this.liteSubscriptionManager.unsubscribeLite(liteTopic);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get the lite topic set.
|
|
111
|
+
*
|
|
112
|
+
* <p>Returns an immutable set of currently subscribed lite topics.
|
|
113
|
+
* This set reflects the current state of subscriptions managed by the lite subscription manager.</p>
|
|
114
|
+
*
|
|
115
|
+
* @return Set of lite topic names
|
|
116
|
+
*/
|
|
117
|
+
getLiteTopicSet() {
|
|
118
|
+
return this.liteSubscriptionManager.getLiteTopicSet();
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get the load balancing group for the consumer.
|
|
122
|
+
*
|
|
123
|
+
* <p>The consumer group is used for load balancing across multiple consumer instances.
|
|
124
|
+
* All consumers in the same group will share the message load.</p>
|
|
125
|
+
*
|
|
126
|
+
* @return Consumer group name
|
|
127
|
+
*/
|
|
128
|
+
getConsumerGroup() {
|
|
129
|
+
return this.liteSubscriptionManager.getConsumerGroupName();
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Handle notify unsubscribe lite command from server.
|
|
133
|
+
*
|
|
134
|
+
* <p>This method is called when the server sends a notification to unsubscribe
|
|
135
|
+
* from a lite topic, typically due to quota violations or administrative actions.</p>
|
|
136
|
+
*
|
|
137
|
+
* @param command - The unsubscribe command from the server
|
|
138
|
+
*/
|
|
139
|
+
onNotifyUnsubscribeLiteCommand(command) {
|
|
140
|
+
this.liteSubscriptionManager.onNotifyUnsubscribeLiteCommand(command);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Handle settings command from server.
|
|
144
|
+
*
|
|
145
|
+
* <p>This method processes configuration updates from the server and synchronizes
|
|
146
|
+
* the lite subscription manager with the latest settings.</p>
|
|
147
|
+
*
|
|
148
|
+
* @param endpoints - The server endpoints
|
|
149
|
+
* @param settings - The settings configuration
|
|
150
|
+
*/
|
|
151
|
+
onSettingsCommand(endpoints, settings) {
|
|
152
|
+
super.onSettingsCommand(endpoints, settings);
|
|
153
|
+
this.liteSubscriptionManager.sync(settings);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Close the consumer.
|
|
157
|
+
*/
|
|
158
|
+
async close() {
|
|
159
|
+
await this.shutdown();
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get the logger.
|
|
163
|
+
*/
|
|
164
|
+
getLogger() {
|
|
165
|
+
return this.logger;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get the RPC client manager (protected access for internal use).
|
|
169
|
+
*
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
getRpcClientManager() {
|
|
173
|
+
return this.rpcClientManager;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get the endpoints (protected access for internal use).
|
|
177
|
+
*
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
getEndpoints() {
|
|
181
|
+
return this.endpoints;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get the request timeout (protected access for internal use).
|
|
185
|
+
*
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
getRequestTimeout() {
|
|
189
|
+
return this.requestTimeout;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.LitePushConsumerImpl = LitePushConsumerImpl;
|
|
193
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTGl0ZVB1c2hDb25zdW1lckltcGwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uc3VtZXIvTGl0ZVB1c2hDb25zdW1lckltcGwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7O0FBRUgsZ0ZBQTBFO0FBRTFFLGdEQUE2QztBQUU3QyxpREFBbUU7QUFHbkUsdUVBQW9FO0FBQ3BFLHlEQUFzRDtBQU10RDs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FpQkc7QUFDSCxNQUFhLG9CQUFxQixTQUFRLDJCQUFZO0lBQ25DLHVCQUF1QixDQUEwQjtJQUNqRCxTQUFTLENBQVc7SUFFckMsWUFBWSxPQUFnQztRQUMxQyxrREFBa0Q7UUFDbEQsTUFBTSxhQUFhLEdBQUcsSUFBSSxHQUFHLEVBQTRCLENBQUM7UUFDMUQsYUFBYSxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsU0FBUyxFQUFFLG1DQUFnQixDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBRS9ELEtBQUssQ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FFRDs7OztPQUlHO0lBQ0gsbUJBQW1CO1FBQ2pCLE9BQU8sSUFBSSxDQUFDLGdCQUFnQixDQUFDO0lBQy9CLENBQUM7SUFFRDs7OztPQUlHO0lBQ0gsWUFBWTtRQUNWLE9BQU8sSUFBSSxDQUFDLFNBQVMsQ0FBQztJQUN4QixDQUFDO0lBRUQ7Ozs7T0FJRztJQUNILGlCQUFpQjtRQUNmLE9BQU8sSUFBSSxDQUFDLGNBQWMsQ0FBQztJQUM3QixDQUFDO0NBQ0Y7QUFuTUQsb0RBbU1DIn0=
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright ownership.
|
|
5
|
+
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
6
|
+
* (the "License"); you may not use this file except in compliance with
|
|
7
|
+
* the License. You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { NotifyUnsubscribeLiteCommand } from '../../proto/apache/rocketmq/v2/service_pb';
|
|
18
|
+
import { Resource } from '../route';
|
|
19
|
+
import { LitePushConsumerImpl } from './LitePushConsumerImpl';
|
|
20
|
+
import { OffsetOption } from './OffsetOption';
|
|
21
|
+
/**
|
|
22
|
+
* Manages lite topic subscriptions for LitePushConsumer.
|
|
23
|
+
*
|
|
24
|
+
* <p>LiteSubscriptionManager handles:
|
|
25
|
+
* - Maintaining the set of subscribed lite topics
|
|
26
|
+
* - Periodic synchronization of lite subscriptions with server
|
|
27
|
+
* - Quota management and verification
|
|
28
|
+
* - Handling unsubscribe commands from server</p>
|
|
29
|
+
*/
|
|
30
|
+
export declare class LiteSubscriptionManager {
|
|
31
|
+
private readonly consumerImpl;
|
|
32
|
+
private readonly bindTopic;
|
|
33
|
+
private readonly group;
|
|
34
|
+
private readonly liteTopicSet;
|
|
35
|
+
private liteSubscriptionQuota;
|
|
36
|
+
private maxLiteTopicSize;
|
|
37
|
+
private syncTimer?;
|
|
38
|
+
constructor(consumerImpl: LitePushConsumerImpl, bindTopic: Resource, group: Resource);
|
|
39
|
+
/**
|
|
40
|
+
* Start periodic sync of lite subscriptions.
|
|
41
|
+
*/
|
|
42
|
+
startUp(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Stop the sync timer.
|
|
45
|
+
*/
|
|
46
|
+
shutdown(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Get the bind topic name.
|
|
49
|
+
*/
|
|
50
|
+
getBindTopicName(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Get the consumer group name.
|
|
53
|
+
*/
|
|
54
|
+
getConsumerGroupName(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Get a copy of the lite topic set.
|
|
57
|
+
*/
|
|
58
|
+
getLiteTopicSet(): Set<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Sync settings from server.
|
|
61
|
+
*/
|
|
62
|
+
sync(settings: any): void;
|
|
63
|
+
/**
|
|
64
|
+
* Subscribe to a lite topic.
|
|
65
|
+
*/
|
|
66
|
+
subscribeLite(liteTopic: string, offsetOption?: OffsetOption | null): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Unsubscribe from a lite topic.
|
|
69
|
+
*/
|
|
70
|
+
unsubscribeLite(liteTopic: string): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Periodic sync of all lite subscriptions.
|
|
73
|
+
*/
|
|
74
|
+
private syncAllLiteSubscription;
|
|
75
|
+
/**
|
|
76
|
+
* Sync lite subscription with server.
|
|
77
|
+
*/
|
|
78
|
+
private syncLiteSubscription;
|
|
79
|
+
/**
|
|
80
|
+
* Handle notify unsubscribe lite command from server.
|
|
81
|
+
*/
|
|
82
|
+
onNotifyUnsubscribeLiteCommand(command: NotifyUnsubscribeLiteCommand): void;
|
|
83
|
+
/**
|
|
84
|
+
* Validate lite topic name.
|
|
85
|
+
*/
|
|
86
|
+
private validateLiteTopic;
|
|
87
|
+
/**
|
|
88
|
+
* Check lite subscription quota.
|
|
89
|
+
*/
|
|
90
|
+
private checkLiteSubscriptionQuota;
|
|
91
|
+
/**
|
|
92
|
+
* Returns a string representation of this LiteSubscriptionManager.
|
|
93
|
+
*
|
|
94
|
+
* @return String representation
|
|
95
|
+
*/
|
|
96
|
+
toString(): string;
|
|
97
|
+
}
|