rocketmq-client-nodejs 1.0.7 → 1.1.0
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 +61 -0
- package/dist/client/BaseClient.d.ts +36 -1
- package/dist/client/BaseClient.js +176 -12
- package/dist/client/RpcClient.js +14 -2
- package/dist/client/RpcClientManager.d.ts +5 -0
- package/dist/client/RpcClientManager.js +25 -8
- package/dist/client/TelemetrySession.js +45 -10
- package/dist/consumer/ConsumeResult.d.ts +2 -2
- package/dist/consumer/ConsumeResult.js +6 -3
- package/dist/consumer/ConsumeService.d.ts +2 -1
- package/dist/consumer/ConsumeService.js +7 -3
- package/dist/consumer/ConsumeTask.d.ts +6 -1
- package/dist/consumer/ConsumeTask.js +36 -5
- package/dist/consumer/Consumer.d.ts +13 -5
- package/dist/consumer/Consumer.js +85 -24
- package/dist/consumer/FifoConsumeService.d.ts +2 -1
- package/dist/consumer/FifoConsumeService.js +3 -3
- package/dist/consumer/LiteFifoConsumeService.d.ts +2 -1
- package/dist/consumer/LiteFifoConsumeService.js +3 -3
- package/dist/consumer/LitePushConsumerImpl.d.ts +12 -1
- package/dist/consumer/LitePushConsumerImpl.js +19 -4
- package/dist/consumer/LiteSimpleConsumer.d.ts +177 -0
- package/dist/consumer/LiteSimpleConsumer.js +126 -0
- package/dist/consumer/LiteSimpleConsumerImpl.d.ts +133 -0
- package/dist/consumer/LiteSimpleConsumerImpl.js +187 -0
- package/dist/consumer/LiteStandardConsumeService.d.ts +2 -1
- package/dist/consumer/LiteStandardConsumeService.js +3 -3
- package/dist/consumer/LiteSubscriptionManager.d.ts +27 -6
- package/dist/consumer/LiteSubscriptionManager.js +32 -24
- package/dist/consumer/ProcessQueue.d.ts +10 -0
- package/dist/consumer/ProcessQueue.js +47 -7
- package/dist/consumer/PushConsumer.d.ts +17 -0
- package/dist/consumer/PushConsumer.js +87 -7
- package/dist/consumer/PushConsumerGaugeObserver.d.ts +33 -0
- package/dist/consumer/PushConsumerGaugeObserver.js +60 -0
- package/dist/consumer/PushSubscriptionSettings.d.ts +8 -1
- package/dist/consumer/PushSubscriptionSettings.js +33 -6
- package/dist/consumer/SimpleConsumer.js +10 -1
- package/dist/consumer/StandardConsumeService.d.ts +2 -1
- package/dist/consumer/StandardConsumeService.js +3 -3
- package/dist/consumer/index.d.ts +1 -0
- package/dist/consumer/index.js +2 -1
- package/dist/exception/PayloadEmptyException.d.ts +20 -0
- package/dist/exception/PayloadEmptyException.js +28 -0
- package/dist/exception/StatusChecker.js +8 -1
- package/dist/exception/index.d.ts +1 -0
- package/dist/exception/index.js +2 -1
- package/dist/hook/Attribute.d.ts +26 -0
- package/dist/hook/Attribute.js +37 -0
- package/dist/hook/AttributeKey.d.ts +32 -0
- package/dist/hook/AttributeKey.js +43 -0
- package/dist/hook/CompositedMessageInterceptor.d.ts +31 -0
- package/dist/hook/CompositedMessageInterceptor.js +84 -0
- package/dist/hook/InflightRequestCountInterceptor.d.ts +28 -0
- package/dist/hook/InflightRequestCountInterceptor.js +44 -0
- package/dist/hook/MessageHookPoints.d.ts +54 -0
- package/dist/hook/MessageHookPoints.js +59 -0
- package/dist/hook/MessageHookPointsStatus.d.ts +24 -0
- package/dist/hook/MessageHookPointsStatus.js +29 -0
- package/dist/hook/MessageInterceptor.d.ts +34 -0
- package/dist/hook/MessageInterceptor.js +19 -0
- package/dist/hook/MessageInterceptorContext.d.ts +31 -0
- package/dist/hook/MessageInterceptorContext.js +19 -0
- package/dist/hook/MessageInterceptorContextImpl.d.ts +39 -0
- package/dist/hook/MessageInterceptorContextImpl.js +57 -0
- package/dist/hook/MessageMeterInterceptor.d.ts +39 -0
- package/dist/hook/MessageMeterInterceptor.js +149 -0
- package/dist/hook/index.d.ts +26 -0
- package/dist/hook/index.js +43 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/metrics/ClientMeter.d.ts +42 -0
- package/dist/metrics/ClientMeter.js +75 -0
- package/dist/metrics/ClientMeterManager.d.ts +42 -0
- package/dist/metrics/ClientMeterManager.js +127 -0
- package/dist/metrics/EmptyGaugeObserver.d.ts +28 -0
- package/dist/metrics/EmptyGaugeObserver.js +34 -0
- package/dist/metrics/GaugeEnum.d.ts +32 -0
- package/dist/metrics/GaugeEnum.js +37 -0
- package/dist/metrics/GaugeObserver.d.ts +29 -0
- package/dist/metrics/GaugeObserver.js +19 -0
- package/dist/metrics/HistogramEnum.d.ts +54 -0
- package/dist/metrics/HistogramEnum.js +71 -0
- package/dist/metrics/InvocationStatus.d.ts +26 -0
- package/dist/metrics/InvocationStatus.js +33 -0
- package/dist/metrics/Metric.d.ts +30 -0
- package/dist/metrics/Metric.js +44 -0
- package/dist/metrics/MetricLabels.d.ts +27 -0
- package/dist/metrics/MetricLabels.js +34 -0
- package/dist/metrics/index.d.ts +25 -0
- package/dist/metrics/index.js +42 -0
- package/dist/producer/Producer.js +33 -5
- package/dist/producer/PublishingLoadBalancer.js +9 -3
- package/dist/retry/CustomizedBackoffRetryPolicy.d.ts +37 -0
- package/dist/retry/CustomizedBackoffRetryPolicy.js +72 -0
- package/dist/retry/ExponentialBackoffRetryPolicy.js +10 -6
- package/dist/retry/RetryPolicy.d.ts +1 -1
- package/dist/retry/index.d.ts +1 -0
- package/dist/retry/index.js +2 -1
- package/dist/route/Endpoints.d.ts +6 -0
- package/dist/route/Endpoints.js +56 -4
- package/dist/route/IpNameResolver.d.ts +28 -0
- package/dist/route/IpNameResolver.js +104 -0
- package/dist/util/Semaphore.d.ts +47 -0
- package/dist/util/Semaphore.js +82 -0
- package/dist/util/index.js +6 -3
- package/package.json +6 -2
- package/src/client/BaseClient.ts +202 -12
- package/src/client/RpcClient.ts +14 -1
- package/src/client/RpcClientManager.ts +27 -8
- package/src/client/TelemetrySession.ts +47 -9
- package/src/consumer/ConsumeResult.ts +5 -2
- package/src/consumer/ConsumeService.ts +9 -2
- package/src/consumer/ConsumeTask.ts +43 -3
- package/src/consumer/Consumer.ts +103 -23
- package/src/consumer/FifoConsumeService.ts +4 -2
- package/src/consumer/LiteFifoConsumeService.ts +4 -2
- package/src/consumer/LitePushConsumerImpl.ts +21 -3
- package/src/consumer/LiteSimpleConsumer.ts +251 -0
- package/src/consumer/LiteSimpleConsumerImpl.ts +221 -0
- package/src/consumer/LiteStandardConsumeService.ts +4 -2
- package/src/consumer/LiteSubscriptionManager.ts +63 -36
- package/src/consumer/ProcessQueue.ts +54 -3
- package/src/consumer/PushConsumer.ts +98 -5
- package/src/consumer/PushConsumerGaugeObserver.ts +60 -0
- package/src/consumer/PushSubscriptionSettings.ts +38 -7
- package/src/consumer/SimpleConsumer.ts +9 -0
- package/src/consumer/StandardConsumeService.ts +4 -2
- package/src/consumer/index.ts +1 -0
- package/src/exception/PayloadEmptyException.ts +25 -0
- package/src/exception/StatusChecker.ts +7 -0
- package/src/exception/index.ts +1 -0
- package/src/hook/Attribute.ts +36 -0
- package/src/hook/AttributeKey.ts +42 -0
- package/src/hook/CompositedMessageInterceptor.ts +92 -0
- package/src/hook/InflightRequestCountInterceptor.ts +46 -0
- package/src/hook/MessageHookPoints.ts +55 -0
- package/src/hook/MessageHookPointsStatus.ts +25 -0
- package/src/hook/MessageInterceptor.ts +35 -0
- package/src/hook/MessageInterceptorContext.ts +33 -0
- package/src/hook/MessageInterceptorContextImpl.ts +68 -0
- package/src/hook/MessageMeterInterceptor.ts +162 -0
- package/src/hook/index.ts +27 -0
- package/src/index.ts +1 -0
- package/src/metrics/ClientMeter.ts +81 -0
- package/src/metrics/ClientMeterManager.ts +145 -0
- package/src/metrics/EmptyGaugeObserver.ts +36 -0
- package/src/metrics/GaugeEnum.ts +33 -0
- package/src/metrics/GaugeObserver.ts +32 -0
- package/src/metrics/HistogramEnum.ts +69 -0
- package/src/metrics/InvocationStatus.ts +28 -0
- package/src/metrics/Metric.ts +42 -0
- package/src/metrics/MetricLabels.ts +31 -0
- package/src/metrics/index.ts +26 -0
- package/src/producer/Producer.ts +37 -6
- package/src/producer/PublishingLoadBalancer.ts +8 -2
- package/src/retry/CustomizedBackoffRetryPolicy.ts +81 -0
- package/src/retry/ExponentialBackoffRetryPolicy.ts +11 -6
- package/src/retry/RetryPolicy.ts +1 -1
- package/src/retry/index.ts +1 -0
- package/src/route/Endpoints.ts +52 -3
- package/src/route/IpNameResolver.ts +119 -0
- package/src/util/Semaphore.ts +82 -0
- package/src/util/index.ts +5 -2
|
@@ -0,0 +1,126 @@
|
|
|
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.LiteSimpleConsumerBuilder = void 0;
|
|
20
|
+
const LiteSimpleConsumerImpl_1 = require("./LiteSimpleConsumerImpl");
|
|
21
|
+
const CONSUMER_GROUP_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
22
|
+
/**
|
|
23
|
+
* LiteSimpleConsumer builder class.
|
|
24
|
+
*
|
|
25
|
+
* <p>This class provides a fluent API for configuring and creating lite simple
|
|
26
|
+
* consumers with explicit receive/ack control over lite topics.</p>
|
|
27
|
+
*/
|
|
28
|
+
class LiteSimpleConsumerBuilder {
|
|
29
|
+
options = {};
|
|
30
|
+
/**
|
|
31
|
+
* Set the bind topic for the lite simple 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 or doesn't match the pattern
|
|
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 await duration for long-polling receive requests.
|
|
77
|
+
*
|
|
78
|
+
* @param awaitDuration - Maximum time to block when no message is available
|
|
79
|
+
* @return This builder instance
|
|
80
|
+
* @throws Error if awaitDuration is not positive
|
|
81
|
+
*/
|
|
82
|
+
setAwaitDuration(awaitDuration) {
|
|
83
|
+
if (awaitDuration <= 0) {
|
|
84
|
+
throw new Error('awaitDuration should be positive');
|
|
85
|
+
}
|
|
86
|
+
this.options.awaitDuration = awaitDuration;
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Finalize the build of LiteSimpleConsumer and start.
|
|
91
|
+
*
|
|
92
|
+
* <p>This method will block until the lite simple consumer starts
|
|
93
|
+
* successfully.</p>
|
|
94
|
+
*
|
|
95
|
+
* @return Promise resolving to started LiteSimpleConsumer instance
|
|
96
|
+
* @throws Error if required parameters are not set
|
|
97
|
+
*/
|
|
98
|
+
async build() {
|
|
99
|
+
if (!this.options.endpoints) {
|
|
100
|
+
throw new Error('clientConfiguration has not been set yet');
|
|
101
|
+
}
|
|
102
|
+
if (!this.options.consumerGroup) {
|
|
103
|
+
throw new Error('consumerGroup has not been set yet');
|
|
104
|
+
}
|
|
105
|
+
if (!this.options.bindTopic) {
|
|
106
|
+
throw new Error('bindTopic has not been set yet');
|
|
107
|
+
}
|
|
108
|
+
const options = {
|
|
109
|
+
endpoints: this.options.endpoints,
|
|
110
|
+
namespace: this.options.namespace ?? '',
|
|
111
|
+
consumerGroup: this.options.consumerGroup,
|
|
112
|
+
bindTopic: this.options.bindTopic,
|
|
113
|
+
awaitDuration: this.options.awaitDuration,
|
|
114
|
+
maxRetryAttempts: this.options.maxRetryAttempts,
|
|
115
|
+
sslEnabled: this.options.sslEnabled,
|
|
116
|
+
sessionCredentials: this.options.sessionCredentials,
|
|
117
|
+
requestTimeout: this.options.requestTimeout,
|
|
118
|
+
logger: this.options.logger,
|
|
119
|
+
};
|
|
120
|
+
const liteSimpleConsumer = new LiteSimpleConsumerImpl_1.LiteSimpleConsumerImpl(options);
|
|
121
|
+
await liteSimpleConsumer.startup();
|
|
122
|
+
return liteSimpleConsumer;
|
|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(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, Settings as SettingsPB } 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 { ILogger } from '../client/Logger';
|
|
21
|
+
import { RpcClientManager } from '../client/RpcClientManager';
|
|
22
|
+
import { SimpleConsumer } from './SimpleConsumer';
|
|
23
|
+
import { LiteSubscriptionHost } from './LiteSubscriptionManager';
|
|
24
|
+
import { OffsetOption } from './OffsetOption';
|
|
25
|
+
import { LiteSimpleConsumer, LiteSimpleConsumerOptions } from './LiteSimpleConsumer';
|
|
26
|
+
/**
|
|
27
|
+
* Keep only the first readable master queue of the route. Lite consumers talk
|
|
28
|
+
* to brokers only through the bound parent topic, so a single queue is enough
|
|
29
|
+
* and it avoids useless route bookkeeping for the other queues.
|
|
30
|
+
*/
|
|
31
|
+
export declare function firstReadableMasterQueue(topicRouteData: TopicRouteData): TopicRouteData;
|
|
32
|
+
/**
|
|
33
|
+
* Implementation of LiteSimpleConsumer.
|
|
34
|
+
*
|
|
35
|
+
* <p>LiteSimpleConsumer extends SimpleConsumer to provide explicit receive/ack
|
|
36
|
+
* control over lite topics. It binds to a single parent topic and manages lite
|
|
37
|
+
* topic subscriptions dynamically via the lite subscription sync protocol.</p>
|
|
38
|
+
*/
|
|
39
|
+
export declare class LiteSimpleConsumerImpl extends SimpleConsumer implements LiteSimpleConsumer, LiteSubscriptionHost {
|
|
40
|
+
#private;
|
|
41
|
+
constructor(options: LiteSimpleConsumerOptions);
|
|
42
|
+
/**
|
|
43
|
+
* Get the client type.
|
|
44
|
+
*
|
|
45
|
+
* @return The client type identifier for lite simple consumer
|
|
46
|
+
*/
|
|
47
|
+
protected getClientType(): ClientType;
|
|
48
|
+
protected onTopicRouteDataUpdate(topic: string, topicRouteData: TopicRouteData): void;
|
|
49
|
+
/**
|
|
50
|
+
* Start up the consumer.
|
|
51
|
+
*
|
|
52
|
+
* <p>This method initializes the consumer and starts the lite subscription
|
|
53
|
+
* manager. It must be called before the consumer can receive messages.</p>
|
|
54
|
+
*/
|
|
55
|
+
startup(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Shutdown the consumer.
|
|
58
|
+
*
|
|
59
|
+
* <p>This method gracefully shuts down the consumer, releasing all resources
|
|
60
|
+
* and stopping the lite subscription manager.</p>
|
|
61
|
+
*/
|
|
62
|
+
shutdown(): Promise<void>;
|
|
63
|
+
subscribeLite(liteTopic: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Subscribe to a lite topic with an offset option to specify the consume
|
|
66
|
+
* from offset.
|
|
67
|
+
*
|
|
68
|
+
* @param liteTopic - The name of the lite topic to subscribe
|
|
69
|
+
* @param offsetOption - The consume from offset option
|
|
70
|
+
*/
|
|
71
|
+
subscribeLite(liteTopic: string, offsetOption: OffsetOption): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Unsubscribe from a lite topic.
|
|
74
|
+
*
|
|
75
|
+
* @param liteTopic - The name of the lite topic to unsubscribe from
|
|
76
|
+
*/
|
|
77
|
+
unsubscribeLite(liteTopic: string): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Get the lite topic set.
|
|
80
|
+
*
|
|
81
|
+
* @return Set of currently subscribed lite topic names
|
|
82
|
+
*/
|
|
83
|
+
getLiteTopicSet(): Set<string>;
|
|
84
|
+
/**
|
|
85
|
+
* Get the load balancing group for the consumer.
|
|
86
|
+
*
|
|
87
|
+
* @return Consumer group name
|
|
88
|
+
*/
|
|
89
|
+
getConsumerGroup(): string;
|
|
90
|
+
/**
|
|
91
|
+
* Handle notify unsubscribe lite command from server.
|
|
92
|
+
*
|
|
93
|
+
* @param _endpoints - The server endpoints
|
|
94
|
+
* @param command - The unsubscribe command from the server
|
|
95
|
+
*/
|
|
96
|
+
onNotifyUnsubscribeLiteCommand(_endpoints: Endpoints, command: NotifyUnsubscribeLiteCommand): void;
|
|
97
|
+
/**
|
|
98
|
+
* Handle settings command from server.
|
|
99
|
+
*
|
|
100
|
+
* @param endpoints - The server endpoints
|
|
101
|
+
* @param settings - The settings configuration
|
|
102
|
+
*/
|
|
103
|
+
onSettingsCommand(endpoints: Endpoints, settings: SettingsPB): void;
|
|
104
|
+
/**
|
|
105
|
+
* Close the consumer.
|
|
106
|
+
*/
|
|
107
|
+
close(): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Get the logger.
|
|
110
|
+
*
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
getLogger(): ILogger;
|
|
114
|
+
/**
|
|
115
|
+
* Get the RPC client manager (protected access for internal use).
|
|
116
|
+
*
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
getRpcClientManager(): RpcClientManager;
|
|
120
|
+
/**
|
|
121
|
+
* Get the request timeout (protected access for internal use).
|
|
122
|
+
*
|
|
123
|
+
* @internal
|
|
124
|
+
*/
|
|
125
|
+
getRequestTimeout(): number;
|
|
126
|
+
/**
|
|
127
|
+
* Endpoints the lite subscription manager should sync to: every endpoint
|
|
128
|
+
* present in the consumed routes.
|
|
129
|
+
*
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
getSyncEndpoints(): Endpoints[];
|
|
133
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
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.LiteSimpleConsumerImpl = void 0;
|
|
20
|
+
exports.firstReadableMasterQueue = firstReadableMasterQueue;
|
|
21
|
+
const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
|
|
22
|
+
const route_1 = require("../route");
|
|
23
|
+
const Resource_1 = require("../route/Resource");
|
|
24
|
+
const util_1 = require("../util");
|
|
25
|
+
const SimpleConsumer_1 = require("./SimpleConsumer");
|
|
26
|
+
const FilterExpression_1 = require("./FilterExpression");
|
|
27
|
+
const LiteSubscriptionManager_1 = require("./LiteSubscriptionManager");
|
|
28
|
+
/**
|
|
29
|
+
* Keep only the first readable master queue of the route. Lite consumers talk
|
|
30
|
+
* to brokers only through the bound parent topic, so a single queue is enough
|
|
31
|
+
* and it avoids useless route bookkeeping for the other queues.
|
|
32
|
+
*/
|
|
33
|
+
function firstReadableMasterQueue(topicRouteData) {
|
|
34
|
+
const readable = topicRouteData.messageQueues.find(mq => mq.broker.id === util_1.MASTER_BROKER_ID &&
|
|
35
|
+
(mq.permission === definition_pb_1.Permission.READ || mq.permission === definition_pb_1.Permission.READ_WRITE));
|
|
36
|
+
return new route_1.TopicRouteData(readable ? [readable.toProtobuf()] : []);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Implementation of LiteSimpleConsumer.
|
|
40
|
+
*
|
|
41
|
+
* <p>LiteSimpleConsumer extends SimpleConsumer to provide explicit receive/ack
|
|
42
|
+
* control over lite topics. It binds to a single parent topic and manages lite
|
|
43
|
+
* topic subscriptions dynamically via the lite subscription sync protocol.</p>
|
|
44
|
+
*/
|
|
45
|
+
class LiteSimpleConsumerImpl extends SimpleConsumer_1.SimpleConsumer {
|
|
46
|
+
#bindTopic;
|
|
47
|
+
#liteSubscriptionManager;
|
|
48
|
+
constructor(options) {
|
|
49
|
+
if (!options.bindTopic || options.bindTopic.trim().length === 0) {
|
|
50
|
+
throw new TypeError('bindTopic should not be blank');
|
|
51
|
+
}
|
|
52
|
+
// Default subscription: (bindTopic, *) for code reuse.
|
|
53
|
+
const subscriptions = new Map()
|
|
54
|
+
.set(options.bindTopic, FilterExpression_1.FilterExpression.SUB_ALL);
|
|
55
|
+
super({
|
|
56
|
+
...options,
|
|
57
|
+
subscriptions,
|
|
58
|
+
});
|
|
59
|
+
this.#bindTopic = new Resource_1.Resource(options.namespace, options.bindTopic);
|
|
60
|
+
const groupResource = new Resource_1.Resource(options.namespace, options.consumerGroup);
|
|
61
|
+
this.#liteSubscriptionManager = new LiteSubscriptionManager_1.LiteSubscriptionManager(this, this.#bindTopic, groupResource);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get the client type.
|
|
65
|
+
*
|
|
66
|
+
* @return The client type identifier for lite simple consumer
|
|
67
|
+
*/
|
|
68
|
+
getClientType() {
|
|
69
|
+
return definition_pb_1.ClientType.LITE_SIMPLE_CONSUMER;
|
|
70
|
+
}
|
|
71
|
+
onTopicRouteDataUpdate(topic, topicRouteData) {
|
|
72
|
+
super.onTopicRouteDataUpdate(topic, firstReadableMasterQueue(topicRouteData));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Start up the consumer.
|
|
76
|
+
*
|
|
77
|
+
* <p>This method initializes the consumer and starts the lite subscription
|
|
78
|
+
* manager. It must be called before the consumer can receive messages.</p>
|
|
79
|
+
*/
|
|
80
|
+
async startup() {
|
|
81
|
+
await super.startup();
|
|
82
|
+
this.#liteSubscriptionManager.startUp();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Shutdown the consumer.
|
|
86
|
+
*
|
|
87
|
+
* <p>This method gracefully shuts down the consumer, releasing all resources
|
|
88
|
+
* and stopping the lite subscription manager.</p>
|
|
89
|
+
*/
|
|
90
|
+
async shutdown() {
|
|
91
|
+
this.#liteSubscriptionManager.shutdown();
|
|
92
|
+
await super.shutdown();
|
|
93
|
+
}
|
|
94
|
+
async subscribeLite(liteTopic, offsetOption) {
|
|
95
|
+
if (!liteTopic || liteTopic.trim().length === 0) {
|
|
96
|
+
throw new Error('liteTopic should not be blank');
|
|
97
|
+
}
|
|
98
|
+
await this.#liteSubscriptionManager.subscribeLite(liteTopic, offsetOption ?? null);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Unsubscribe from a lite topic.
|
|
102
|
+
*
|
|
103
|
+
* @param liteTopic - The name of the lite topic to unsubscribe from
|
|
104
|
+
*/
|
|
105
|
+
async unsubscribeLite(liteTopic) {
|
|
106
|
+
if (!liteTopic || liteTopic.trim().length === 0) {
|
|
107
|
+
throw new Error('liteTopic should not be blank');
|
|
108
|
+
}
|
|
109
|
+
await this.#liteSubscriptionManager.unsubscribeLite(liteTopic);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get the lite topic set.
|
|
113
|
+
*
|
|
114
|
+
* @return Set of currently subscribed lite topic names
|
|
115
|
+
*/
|
|
116
|
+
getLiteTopicSet() {
|
|
117
|
+
return this.#liteSubscriptionManager.getLiteTopicSet();
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get the load balancing group for the consumer.
|
|
121
|
+
*
|
|
122
|
+
* @return Consumer group name
|
|
123
|
+
*/
|
|
124
|
+
getConsumerGroup() {
|
|
125
|
+
return this.#liteSubscriptionManager.getConsumerGroupName();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Handle notify unsubscribe lite command from server.
|
|
129
|
+
*
|
|
130
|
+
* @param _endpoints - The server endpoints
|
|
131
|
+
* @param command - The unsubscribe command from the server
|
|
132
|
+
*/
|
|
133
|
+
onNotifyUnsubscribeLiteCommand(_endpoints, command) {
|
|
134
|
+
this.#liteSubscriptionManager.onNotifyUnsubscribeLiteCommand(command);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Handle settings command from server.
|
|
138
|
+
*
|
|
139
|
+
* @param endpoints - The server endpoints
|
|
140
|
+
* @param settings - The settings configuration
|
|
141
|
+
*/
|
|
142
|
+
onSettingsCommand(endpoints, settings) {
|
|
143
|
+
super.onSettingsCommand(endpoints, settings);
|
|
144
|
+
this.#liteSubscriptionManager.sync(settings);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Close the consumer.
|
|
148
|
+
*/
|
|
149
|
+
async close() {
|
|
150
|
+
await this.shutdown();
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get the logger.
|
|
154
|
+
*
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
157
|
+
getLogger() {
|
|
158
|
+
return this.logger;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get the RPC client manager (protected access for internal use).
|
|
162
|
+
*
|
|
163
|
+
* @internal
|
|
164
|
+
*/
|
|
165
|
+
getRpcClientManager() {
|
|
166
|
+
return this.rpcClientManager;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get the request timeout (protected access for internal use).
|
|
170
|
+
*
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
getRequestTimeout() {
|
|
174
|
+
return this.requestTimeout;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Endpoints the lite subscription manager should sync to: every endpoint
|
|
178
|
+
* present in the consumed routes.
|
|
179
|
+
*
|
|
180
|
+
* @internal
|
|
181
|
+
*/
|
|
182
|
+
getSyncEndpoints() {
|
|
183
|
+
return this.getTotalRouteEndpoints();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.LiteSimpleConsumerImpl = LiteSimpleConsumerImpl;
|
|
187
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTGl0ZVNpbXBsZUNvbnN1bWVySW1wbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb25zdW1lci9MaXRlU2ltcGxlQ29uc3VtZXJJbXBsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7OztBQW9CSCw0REFNQztBQXhCRCxnRkFBOEc7QUFFOUcsb0NBQXFEO0FBQ3JELGdEQUE2QztBQUM3QyxrQ0FBMkM7QUFHM0MscURBQXlFO0FBQ3pFLHlEQUFzRDtBQUN0RCx1RUFBMEY7QUFJMUY7Ozs7R0FJRztBQUNILFNBQWdCLHdCQUF3QixDQUFDLGNBQThCO0lBQ3JFLE1BQU0sUUFBUSxHQUFHLGNBQWMsQ0FBQyxhQUFhLENBQUMsSUFBSSxDQUNoRCxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxNQUFNLENBQUMsRUFBRSxLQUFLLHVCQUFnQjtRQUNyQyxDQUFDLEVBQUUsQ0FBQyxVQUFVLEtBQUssMEJBQVUsQ0FBQyxJQUFJLElBQUksRUFBRSxDQUFDLFVBQVUsS0FBSywwQkFBVSxDQUFDLFVBQVUsQ0F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G1CQUFtQjtRQUNqQixPQUFPLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQztJQUMvQixDQUFDO0lBRUQ7Ozs7T0FJRztJQUNILGlCQUFpQjtRQUNmLE9BQU8sSUFBSSxDQUFDLGNBQWMsQ0FBQztJQUM3QixDQUFDO0lBRUQ7Ozs7O09BS0c7SUFDSCxnQkFBZ0I7UUFDZCxPQUFPLElBQUksQ0FBQyxzQkFBc0IsRUFBRSxDQUFDO0lBQ3ZDLENBQUM7Q0FDRjtBQTFLRCx3REEwS0MifQ==
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { MessageView } from '../message';
|
|
18
|
+
import { MessageInterceptor } from '../hook';
|
|
18
19
|
import { ConsumeService } from './ConsumeService';
|
|
19
20
|
import { MessageListener } from './MessageListener';
|
|
20
21
|
import type { ProcessQueue } from './ProcessQueue';
|
|
@@ -27,6 +28,6 @@ import type { ProcessQueue } from './ProcessQueue';
|
|
|
27
28
|
*/
|
|
28
29
|
export declare class LiteStandardConsumeService extends ConsumeService {
|
|
29
30
|
#private;
|
|
30
|
-
constructor(clientId: string, messageListener: MessageListener);
|
|
31
|
+
constructor(clientId: string, messageListener: MessageListener, messageInterceptor?: MessageInterceptor, consumerGroup?: string);
|
|
31
32
|
consume(pq: ProcessQueue, messageViews: MessageView[]): void;
|
|
32
33
|
}
|
|
@@ -28,8 +28,8 @@ const Logger_1 = require("../client/Logger");
|
|
|
28
28
|
*/
|
|
29
29
|
class LiteStandardConsumeService extends ConsumeService_1.ConsumeService {
|
|
30
30
|
#logger;
|
|
31
|
-
constructor(clientId, messageListener) {
|
|
32
|
-
super(clientId, messageListener);
|
|
31
|
+
constructor(clientId, messageListener, messageInterceptor, consumerGroup) {
|
|
32
|
+
super(clientId, messageListener, messageInterceptor, consumerGroup);
|
|
33
33
|
this.#logger = (0, Logger_1.getDefaultLogger)();
|
|
34
34
|
}
|
|
35
35
|
consume(pq, messageViews) {
|
|
@@ -60,4 +60,4 @@ class LiteStandardConsumeService extends ConsumeService_1.ConsumeService {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
exports.LiteStandardConsumeService = LiteStandardConsumeService;
|
|
63
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
63
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTGl0ZVN0YW5kYXJkQ29uc3VtZVNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uc3VtZXIvTGl0ZVN0YW5kYXJkQ29uc3VtZVNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7O0FBSUgscURBQWtEO0FBR2xELDZDQUE2RDtBQUU3RDs7Ozs7O0dBTUc7QUFDSCxNQUFhLDBCQUEyQixTQUFRLCtCQUFjO0lBQ25ELE9BQU8sQ0FBVTtJQUUxQixZQUFZLFFBQWdCLEVBQUUsZUFBZ0MsRUFDNUQsa0JBQXVDLEVBQUUsYUFBc0I7UUFDL0QsS0FBSyxDQUFDLFFBQVEsRUFBRSxlQUFlLEVBQUUsa0JBQWtCLEVBQUUsYUFBYSxDQUFDLENBQUM7UUFDcEUsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFBLHlCQUFnQixHQUFFLENBQUM7SUFDcEMsQ0FBQztJQUVELE9BQU8sQ0FBQyxFQUFnQixFQUFFLFlBQTJCO1FBQ25ELElBQUksQ0FBQyxFQUFFLElBQUksQ0FBQyxZQUFZLEVBQUUsQ0FBQztZQUN6QixJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQywwRUFBMEUsRUFBRSxFQUFFLEVBQUUsWUFBWSxFQUFFLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztZQUNoSSxPQUFPO1FBQ1QsQ0FBQztRQUVELElBQUksQ0FBQ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FDLEVBQUU7Z0JBQ1gsMkJBQTJCO2dCQUMzQixJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxxRkFBcUYsRUFDdEcsSUFBSSxDQUFDLFFBQVEsRUFBRSxHQUFHLENBQUMsQ0FBQztZQUN4QixDQUFDLENBQUMsQ0FBQztRQUNQLENBQUM7SUFDSCxDQUFDO0NBQ0Y7QUEzQ0QsZ0VBMkNDIn0=
|
|
@@ -15,11 +15,32 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { NotifyUnsubscribeLiteCommand } from '../../proto/apache/rocketmq/v2/service_pb';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import { Endpoints } from '../route';
|
|
19
|
+
import { ILogger } from '../client/Logger';
|
|
20
|
+
import { RpcClientManager } from '../client/RpcClientManager';
|
|
21
|
+
import { Resource } from '../route/Resource';
|
|
20
22
|
import { OffsetOption } from './OffsetOption';
|
|
21
23
|
/**
|
|
22
|
-
*
|
|
24
|
+
* Minimal host contract required by LiteSubscriptionManager.
|
|
25
|
+
*
|
|
26
|
+
* Implemented by LitePushConsumerImpl and LiteSimpleConsumerImpl so the same
|
|
27
|
+
* manager can keep lite subscriptions in sync for both consumer flavors.
|
|
28
|
+
*/
|
|
29
|
+
export interface LiteSubscriptionHost {
|
|
30
|
+
clientId: string;
|
|
31
|
+
isRunning(): boolean;
|
|
32
|
+
getLogger(): ILogger;
|
|
33
|
+
getRpcClientManager(): RpcClientManager;
|
|
34
|
+
getRequestTimeout(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Endpoints the lite subscription should be synced to. Lite subscriptions
|
|
37
|
+
* must reach every route endpoint, not only the endpoint the client was
|
|
38
|
+
* configured with.
|
|
39
|
+
*/
|
|
40
|
+
getSyncEndpoints(): Endpoints[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Manages lite topic subscriptions for lite consumers.
|
|
23
44
|
*
|
|
24
45
|
* <p>LiteSubscriptionManager handles:
|
|
25
46
|
* - Maintaining the set of subscribed lite topics
|
|
@@ -28,14 +49,14 @@ import { OffsetOption } from './OffsetOption';
|
|
|
28
49
|
* - Handling unsubscribe commands from server</p>
|
|
29
50
|
*/
|
|
30
51
|
export declare class LiteSubscriptionManager {
|
|
31
|
-
private readonly
|
|
52
|
+
private readonly host;
|
|
32
53
|
private readonly bindTopic;
|
|
33
54
|
private readonly group;
|
|
34
55
|
private readonly liteTopicSet;
|
|
35
56
|
private liteSubscriptionQuota;
|
|
36
57
|
private maxLiteTopicSize;
|
|
37
58
|
private syncTimer?;
|
|
38
|
-
constructor(
|
|
59
|
+
constructor(host: LiteSubscriptionHost, bindTopic: Resource, group: Resource);
|
|
39
60
|
/**
|
|
40
61
|
* Start periodic sync of lite subscriptions.
|
|
41
62
|
*/
|
|
@@ -73,7 +94,7 @@ export declare class LiteSubscriptionManager {
|
|
|
73
94
|
*/
|
|
74
95
|
private syncAllLiteSubscription;
|
|
75
96
|
/**
|
|
76
|
-
* Sync lite subscription with
|
|
97
|
+
* Sync lite subscription with every route endpoint.
|
|
77
98
|
*/
|
|
78
99
|
private syncLiteSubscription;
|
|
79
100
|
/**
|