rocketmq-client-nodejs 1.0.8 → 1.1.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.
- package/README.md +61 -0
- package/dist/client/BaseClient.d.ts +44 -1
- package/dist/client/BaseClient.js +353 -85
- package/dist/client/Logger.js +9 -6
- package/dist/client/RpcClient.js +42 -134
- package/dist/client/RpcClientManager.d.ts +22 -17
- package/dist/client/RpcClientManager.js +61 -56
- package/dist/client/TelemetrySession.js +107 -17
- package/dist/consumer/ConsumeService.d.ts +2 -1
- package/dist/consumer/ConsumeService.js +12 -6
- 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 +94 -33
- package/dist/consumer/FifoConsumeService.d.ts +3 -1
- package/dist/consumer/FifoConsumeService.js +4 -4
- package/dist/consumer/LiteConsumerSupport.d.ts +25 -0
- package/dist/consumer/LiteConsumerSupport.js +47 -0
- package/dist/consumer/LiteFifoConsumeService.d.ts +3 -1
- package/dist/consumer/LiteFifoConsumeService.js +4 -4
- package/dist/consumer/LitePushConsumerImpl.d.ts +15 -4
- package/dist/consumer/LitePushConsumerImpl.js +26 -30
- 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 +179 -0
- package/dist/consumer/LiteStandardConsumeService.d.ts +3 -1
- package/dist/consumer/LiteStandardConsumeService.js +4 -4
- package/dist/consumer/LiteSubscriptionManager.d.ts +27 -6
- package/dist/consumer/LiteSubscriptionManager.js +36 -27
- package/dist/consumer/OffsetOption.d.ts +1 -0
- package/dist/consumer/OffsetOption.js +10 -4
- package/dist/consumer/ProcessQueue.d.ts +17 -1
- package/dist/consumer/ProcessQueue.js +134 -91
- package/dist/consumer/PushConsumer.d.ts +17 -0
- package/dist/consumer/PushConsumer.js +117 -26
- 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 +35 -8
- package/dist/consumer/SimpleConsumer.d.ts +5 -0
- package/dist/consumer/SimpleConsumer.js +33 -20
- package/dist/consumer/SimpleSubscriptionSettings.js +3 -3
- package/dist/consumer/StandardConsumeService.d.ts +3 -1
- package/dist/consumer/StandardConsumeService.js +17 -8
- package/dist/consumer/SubscriptionLoadBalancer.js +3 -3
- package/dist/consumer/index.d.ts +1 -0
- package/dist/consumer/index.js +2 -1
- package/dist/exception/InternalErrorException.d.ts +1 -0
- package/dist/exception/InternalErrorException.js +3 -2
- package/dist/exception/PayloadEmptyException.d.ts +20 -0
- package/dist/exception/PayloadEmptyException.js +28 -0
- package/dist/exception/StatusChecker.js +11 -4
- package/dist/exception/index.d.ts +1 -0
- package/dist/exception/index.js +2 -1
- package/dist/exception/receiveStatus.d.ts +18 -0
- package/dist/exception/receiveStatus.js +28 -0
- 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 +32 -0
- package/dist/hook/CompositedMessageInterceptor.js +87 -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 +40 -0
- package/dist/hook/MessageInterceptorContextImpl.js +71 -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/message/Message.js +26 -4
- package/dist/message/MessageView.js +15 -5
- package/dist/message/PublishingMessage.js +4 -4
- package/dist/metrics/ClientMeter.d.ts +42 -0
- package/dist/metrics/ClientMeter.js +75 -0
- package/dist/metrics/ClientMeterManager.d.ts +46 -0
- package/dist/metrics/ClientMeterManager.js +203 -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.d.ts +8 -2
- package/dist/producer/Producer.js +83 -34
- package/dist/producer/PublishingLoadBalancer.js +11 -5
- package/dist/producer/PublishingSettings.js +1 -3
- package/dist/producer/SendReceipt.js +3 -2
- package/dist/producer/Transaction.d.ts +2 -1
- package/dist/producer/Transaction.js +9 -8
- package/dist/producer/index.d.ts +1 -0
- package/dist/producer/index.js +2 -2
- 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 +69 -9
- package/dist/route/IpNameResolver.d.ts +28 -0
- package/dist/route/IpNameResolver.js +104 -0
- package/dist/route/MessageQueue.js +7 -2
- package/dist/route/TopicRouteData.d.ts +5 -0
- package/dist/route/TopicRouteData.js +22 -1
- package/dist/util/Semaphore.d.ts +47 -0
- package/dist/util/Semaphore.js +82 -0
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.js +9 -6
- package/dist/util/rpcContext.d.ts +20 -0
- package/dist/util/rpcContext.js +35 -0
- package/package.json +11 -4
- package/src/client/BaseClient.ts +392 -91
- package/src/client/Logger.ts +9 -5
- package/src/client/RpcClient.ts +62 -133
- package/src/client/RpcClientManager.ts +103 -60
- package/src/client/TelemetrySession.ts +112 -17
- package/src/consumer/ConsumeService.ts +16 -5
- package/src/consumer/ConsumeTask.ts +43 -3
- package/src/consumer/Consumer.ts +116 -35
- package/src/consumer/FifoConsumeService.ts +5 -3
- package/src/consumer/LiteConsumerSupport.ts +49 -0
- package/src/consumer/LiteFifoConsumeService.ts +5 -3
- package/src/consumer/LitePushConsumerImpl.ts +34 -23
- package/src/consumer/LiteSimpleConsumer.ts +251 -0
- package/src/consumer/LiteSimpleConsumerImpl.ts +214 -0
- package/src/consumer/LiteStandardConsumeService.ts +5 -3
- package/src/consumer/LiteSubscriptionManager.ts +66 -41
- package/src/consumer/OffsetOption.ts +10 -3
- package/src/consumer/ProcessQueue.ts +165 -107
- package/src/consumer/PushConsumer.ts +133 -24
- package/src/consumer/PushConsumerGaugeObserver.ts +60 -0
- package/src/consumer/PushSubscriptionSettings.ts +40 -9
- package/src/consumer/SimpleConsumer.ts +39 -23
- package/src/consumer/SimpleSubscriptionSettings.ts +2 -2
- package/src/consumer/StandardConsumeService.ts +18 -7
- package/src/consumer/SubscriptionLoadBalancer.ts +2 -2
- package/src/consumer/index.ts +1 -0
- package/src/exception/InternalErrorException.ts +3 -1
- package/src/exception/PayloadEmptyException.ts +25 -0
- package/src/exception/StatusChecker.ts +10 -2
- package/src/exception/index.ts +1 -0
- package/src/exception/receiveStatus.ts +25 -0
- package/src/hook/Attribute.ts +36 -0
- package/src/hook/AttributeKey.ts +42 -0
- package/src/hook/CompositedMessageInterceptor.ts +96 -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 +83 -0
- package/src/hook/MessageMeterInterceptor.ts +162 -0
- package/src/hook/index.ts +27 -0
- package/src/index.ts +1 -0
- package/src/message/Message.ts +25 -3
- package/src/message/MessageView.ts +13 -4
- package/src/message/PublishingMessage.ts +3 -3
- package/src/metrics/ClientMeter.ts +81 -0
- package/src/metrics/ClientMeterManager.ts +227 -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 +94 -38
- package/src/producer/PublishingLoadBalancer.ts +10 -4
- package/src/producer/PublishingSettings.ts +0 -2
- package/src/producer/SendReceipt.ts +2 -1
- package/src/producer/Transaction.ts +12 -11
- package/src/producer/index.ts +1 -1
- 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 +65 -8
- package/src/route/IpNameResolver.ts +119 -0
- package/src/route/MessageQueue.ts +6 -1
- package/src/route/TopicRouteData.ts +22 -1
- package/src/util/Semaphore.ts +82 -0
- package/src/util/index.ts +8 -5
- package/src/util/rpcContext.ts +34 -0
|
@@ -0,0 +1,177 @@
|
|
|
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 { BaseClientOptions } from '../client';
|
|
18
|
+
import { MessageView } from '../message';
|
|
19
|
+
import { OffsetOption } from './OffsetOption';
|
|
20
|
+
/**
|
|
21
|
+
* LiteSimpleConsumer interface for consuming messages from lite topics with
|
|
22
|
+
* explicit receive/ack control.
|
|
23
|
+
*
|
|
24
|
+
* <p>Similar to SimpleConsumer, but bound to a single parent topic and able to
|
|
25
|
+
* (un)subscribe lite topics dynamically through the lite subscription sync
|
|
26
|
+
* protocol.</p>
|
|
27
|
+
*/
|
|
28
|
+
export interface LiteSimpleConsumer {
|
|
29
|
+
/**
|
|
30
|
+
* Get the load balancing group for the lite simple consumer.
|
|
31
|
+
*
|
|
32
|
+
* @return Consumer load balancing group
|
|
33
|
+
*/
|
|
34
|
+
getConsumerGroup(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Subscribe to a lite topic.
|
|
37
|
+
*
|
|
38
|
+
* <p>The subscribeLite() method initiates network requests and performs quota
|
|
39
|
+
* verification, so it may fail. It's important to check the result of this
|
|
40
|
+
* call to ensure that the subscription was successfully added. Possible
|
|
41
|
+
* failure scenarios include:</p>
|
|
42
|
+
* <ul>
|
|
43
|
+
* <li>Network request errors, which can be retried.</li>
|
|
44
|
+
* <li>Quota verification failures, indicated by LiteSubscriptionQuotaExceededException.
|
|
45
|
+
* In this case, evaluate whether the quota is insufficient and promptly
|
|
46
|
+
* unsubscribe from unused subscriptions using unsubscribeLite() to free
|
|
47
|
+
* up resources.</li>
|
|
48
|
+
* </ul>
|
|
49
|
+
*
|
|
50
|
+
* @param liteTopic - The name of the lite topic to subscribe
|
|
51
|
+
* @throws ClientException if an error occurs during subscription
|
|
52
|
+
*/
|
|
53
|
+
subscribeLite(liteTopic: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Subscribe to a lite topic with an offset option to specify the consume from
|
|
56
|
+
* offset.
|
|
57
|
+
*
|
|
58
|
+
* @param liteTopic - The name of the lite topic to subscribe
|
|
59
|
+
* @param offsetOption - The consume from offset option
|
|
60
|
+
* @throws ClientException if an error occurs during subscription
|
|
61
|
+
*/
|
|
62
|
+
subscribeLite(liteTopic: string, offsetOption: OffsetOption): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Unsubscribe from a lite topic.
|
|
65
|
+
*
|
|
66
|
+
* @param liteTopic - The name of the lite topic to unsubscribe from
|
|
67
|
+
* @throws ClientException if an error occurs during unsubscription
|
|
68
|
+
*/
|
|
69
|
+
unsubscribeLite(liteTopic: string): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Get the lite topic immutable set.
|
|
72
|
+
*
|
|
73
|
+
* @return Lite topic immutable set
|
|
74
|
+
*/
|
|
75
|
+
getLiteTopicSet(): Set<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Fetch messages from the server synchronously.
|
|
78
|
+
*
|
|
79
|
+
* <p>This method returns immediately if there are messages available.
|
|
80
|
+
* Otherwise, it will await the passed timeout. If the timeout expires, an
|
|
81
|
+
* empty list will be returned.</p>
|
|
82
|
+
*
|
|
83
|
+
* @param maxMessageNum - Max message num of server returned
|
|
84
|
+
* @param invisibleDuration - Set the invisibleDuration of messages to return
|
|
85
|
+
* @return List of message views
|
|
86
|
+
*/
|
|
87
|
+
receive(maxMessageNum?: number, invisibleDuration?: number): Promise<MessageView[]>;
|
|
88
|
+
/**
|
|
89
|
+
* Ack the consumption of the message which is returned by receive().
|
|
90
|
+
*
|
|
91
|
+
* @param messageView - Message view with the receipt handle to ack
|
|
92
|
+
* @throws ClientException if an error occurs during ack
|
|
93
|
+
*/
|
|
94
|
+
ack(messageView: MessageView): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Change the invisible duration of a received message.
|
|
97
|
+
*
|
|
98
|
+
* @param messageView - Message view to change invisible duration
|
|
99
|
+
* @param invisibleDuration - New invisible duration
|
|
100
|
+
* @throws ClientException if an error occurs
|
|
101
|
+
*/
|
|
102
|
+
changeInvisibleDuration(messageView: MessageView, invisibleDuration: number): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Close the consumer and release all related resources.
|
|
105
|
+
*
|
|
106
|
+
* <p>Once the consumer is closed, <strong>it could not be started once
|
|
107
|
+
* again.</strong></p>
|
|
108
|
+
*/
|
|
109
|
+
close(): Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
export interface LiteSimpleConsumerOptions extends BaseClientOptions {
|
|
112
|
+
consumerGroup: string;
|
|
113
|
+
/**
|
|
114
|
+
* The parent topic the lite consumer binds to. All lite topics subscribed by
|
|
115
|
+
* this consumer must belong to this parent topic.
|
|
116
|
+
*/
|
|
117
|
+
bindTopic: string;
|
|
118
|
+
/**
|
|
119
|
+
* set await duration for long-polling, default is 30000ms
|
|
120
|
+
*/
|
|
121
|
+
awaitDuration?: number;
|
|
122
|
+
/**
|
|
123
|
+
* max retry attempts for temporary errors (e.g., internal server error), default is 3
|
|
124
|
+
*/
|
|
125
|
+
maxRetryAttempts?: number;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* LiteSimpleConsumer builder class.
|
|
129
|
+
*
|
|
130
|
+
* <p>This class provides a fluent API for configuring and creating lite simple
|
|
131
|
+
* consumers with explicit receive/ack control over lite topics.</p>
|
|
132
|
+
*/
|
|
133
|
+
export declare class LiteSimpleConsumerBuilder {
|
|
134
|
+
private options;
|
|
135
|
+
/**
|
|
136
|
+
* Set the bind topic for the lite simple consumer.
|
|
137
|
+
*
|
|
138
|
+
* @param bindTopic - The parent topic to bind
|
|
139
|
+
* @return This builder instance
|
|
140
|
+
* @throws Error if bindTopic is blank
|
|
141
|
+
*/
|
|
142
|
+
bindTopic(bindTopic: string): LiteSimpleConsumerBuilder;
|
|
143
|
+
/**
|
|
144
|
+
* Set the client configuration.
|
|
145
|
+
*
|
|
146
|
+
* @param options - Client configuration options
|
|
147
|
+
* @return This builder instance
|
|
148
|
+
* @throws Error if options is null/undefined
|
|
149
|
+
*/
|
|
150
|
+
setClientConfiguration(options: BaseClientOptions): LiteSimpleConsumerBuilder;
|
|
151
|
+
/**
|
|
152
|
+
* Set the consumer group.
|
|
153
|
+
*
|
|
154
|
+
* @param consumerGroup - Consumer group name
|
|
155
|
+
* @return This builder instance
|
|
156
|
+
* @throws Error if consumerGroup is null or doesn't match the pattern
|
|
157
|
+
*/
|
|
158
|
+
setConsumerGroup(consumerGroup: string): LiteSimpleConsumerBuilder;
|
|
159
|
+
/**
|
|
160
|
+
* Set the await duration for long-polling receive requests.
|
|
161
|
+
*
|
|
162
|
+
* @param awaitDuration - Maximum time to block when no message is available
|
|
163
|
+
* @return This builder instance
|
|
164
|
+
* @throws Error if awaitDuration is not positive
|
|
165
|
+
*/
|
|
166
|
+
setAwaitDuration(awaitDuration: number): LiteSimpleConsumerBuilder;
|
|
167
|
+
/**
|
|
168
|
+
* Finalize the build of LiteSimpleConsumer and start.
|
|
169
|
+
*
|
|
170
|
+
* <p>This method will block until the lite simple consumer starts
|
|
171
|
+
* successfully.</p>
|
|
172
|
+
*
|
|
173
|
+
* @return Promise resolving to started LiteSimpleConsumer instance
|
|
174
|
+
* @throws Error if required parameters are not set
|
|
175
|
+
*/
|
|
176
|
+
build(): Promise<LiteSimpleConsumer>;
|
|
177
|
+
}
|
|
@@ -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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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, 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,179 @@
|
|
|
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 LiteConsumerSupport_1 = require("./LiteConsumerSupport");
|
|
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 LiteConsumerSupport_1.LiteConsumerSupport(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 this.#liteSubscriptionManager.startConsumer(() => super.startup());
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Shutdown the consumer.
|
|
85
|
+
*
|
|
86
|
+
* <p>This method gracefully shuts down the consumer, releasing all resources
|
|
87
|
+
* and stopping the lite subscription manager.</p>
|
|
88
|
+
*/
|
|
89
|
+
async shutdown() {
|
|
90
|
+
await this.#liteSubscriptionManager.shutdownConsumer(() => super.shutdown());
|
|
91
|
+
}
|
|
92
|
+
async subscribeLite(liteTopic, offsetOption) {
|
|
93
|
+
await this.#liteSubscriptionManager.subscribeLite(liteTopic, offsetOption);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Unsubscribe from a lite topic.
|
|
97
|
+
*
|
|
98
|
+
* @param liteTopic - The name of the lite topic to unsubscribe from
|
|
99
|
+
*/
|
|
100
|
+
async unsubscribeLite(liteTopic) {
|
|
101
|
+
await this.#liteSubscriptionManager.unsubscribeLite(liteTopic);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get the lite topic set.
|
|
105
|
+
*
|
|
106
|
+
* @return Set of currently subscribed lite topic names
|
|
107
|
+
*/
|
|
108
|
+
getLiteTopicSet() {
|
|
109
|
+
return this.#liteSubscriptionManager.getLiteTopicSet();
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get the load balancing group for the consumer.
|
|
113
|
+
*
|
|
114
|
+
* @return Consumer group name
|
|
115
|
+
*/
|
|
116
|
+
getConsumerGroup() {
|
|
117
|
+
return this.#liteSubscriptionManager.getConsumerGroupName();
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Handle notify unsubscribe lite command from server.
|
|
121
|
+
*
|
|
122
|
+
* @param _endpoints - The server endpoints
|
|
123
|
+
* @param command - The unsubscribe command from the server
|
|
124
|
+
*/
|
|
125
|
+
onNotifyUnsubscribeLiteCommand(_endpoints, command) {
|
|
126
|
+
this.#liteSubscriptionManager.onNotifyUnsubscribeLiteCommand(command);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Handle settings command from server.
|
|
130
|
+
*
|
|
131
|
+
* @param endpoints - The server endpoints
|
|
132
|
+
* @param settings - The settings configuration
|
|
133
|
+
*/
|
|
134
|
+
onSettingsCommand(endpoints, settings) {
|
|
135
|
+
super.onSettingsCommand(endpoints, settings);
|
|
136
|
+
this.#liteSubscriptionManager.sync(settings);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Close the consumer.
|
|
140
|
+
*/
|
|
141
|
+
async close() {
|
|
142
|
+
await this.shutdown();
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get the logger.
|
|
146
|
+
*
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
getLogger() {
|
|
150
|
+
return this.logger;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get the RPC client manager (protected access for internal use).
|
|
154
|
+
*
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
157
|
+
getRpcClientManager() {
|
|
158
|
+
return this.rpcClientManager;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get the request timeout (protected access for internal use).
|
|
162
|
+
*
|
|
163
|
+
* @internal
|
|
164
|
+
*/
|
|
165
|
+
getRequestTimeout() {
|
|
166
|
+
return this.requestTimeout;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Endpoints the lite subscription manager should sync to: every endpoint
|
|
170
|
+
* present in the consumed routes.
|
|
171
|
+
*
|
|
172
|
+
* @internal
|
|
173
|
+
*/
|
|
174
|
+
getSyncEndpoints() {
|
|
175
|
+
return this.getTotalRouteEndpoints();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.LiteSimpleConsumerImpl = LiteSimpleConsumerImpl;
|
|
179
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTGl0ZVNpbXBsZUNvbnN1bWVySW1wbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb25zdW1lci9MaXRlU2ltcGxlQ29uc3VtZXJJbXBsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7OztBQXFCSCw0REFNQztBQXpCRCxnRkFBOEc7QUFFOUcsb0NBQXFEO0FBQ3JELGdEQUE2QztBQUM3QyxrQ0FBMkM7QUFHM0MscURBQXlFO0FBQ3pFLHlEQUFzRDtBQUV0RCwrREFBNEQ7QUFJNUQ7Ozs7R0FJRztBQUNILFNBQWdCLHdCQUF3QixDQUFDLGNBQThCO0lBQ3JFLE1BQU0sUUFBUSxHQUFHLGNBQWMsQ0FBQyxhQUFhLENBQUMsSUFBSSxDQUNoRCxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxNQUFNLENBQUMsRUFBRSxLQUFLLHVCQUFnQjtRQUNyQyxDQUFDLEVBQUUsQ0FBQyxVQUFVLEtBQUssMEJBQVUsQ0FBQyxJQUFJLElBQUksRUFBRSxDQUFDLFVBQVUsS0FBSywwQkFBVSxDQUFDLFVBQVUsQ0FBQyxDQUNqRixDQUFDO0lBQ0YsT0FBTyxJQUFJLHNCQUFjLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQyxDQUFFLFFBQVEsQ0FBQyxVQUFVLEVBQUUsQ0FBRSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQztBQUN2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QThCLENBQUMsVUFBcUIsRUFBRSxPQUFxQztRQUN6RixJQUFJLENBQUMsd0JBQXdCLENBQUMsOEJBQThCLENBQUMsT0FBTyxDQUFDLENBQUM7SUFDeEUsQ0FBQztJQUVEOzs7OztPQUtHO0lBQ0gsaUJBQWlCLENBQUMsU0FBb0IsRUFBRSxRQUFvQjtRQUMxRCxLQUFLLENBQUMsaUJBQWlCLENBQUMsU0FBUyxFQUFFLFFBQVEsQ0FBQyxDQUFDO1FBQzdDLElBQUksQ0FBQyx3QkFBd0IsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUM7SUFDL0MsQ0FBQztJQUVEOztPQUVHO0lBQ0gsS0FBSyxDQUFDLEtBQUs7UUFDVCxNQUFNLElBQUksQ0FBQyxRQUFRLEVBQUUsQ0FBQztJQUN4QixDQUFDO0lBRUQ7Ozs7T0FJRztJQUNILFNBQVM7UUFDUCxPQUFPLElBQUksQ0FBQyxNQUFNLENBQUM7SUFDckIsQ0FBQztJQUVEOzs7O09BSUc7SUFDSCxtQkFBbUI7UUFDakIsT0FBTyxJQUFJLENBQUMsZ0JBQWdCLENBQUM7SUFDL0IsQ0FBQztJQUVEOzs7O09BSUc7SUFDSCxpQkFBaUI7UUFDZixPQUFPLElBQUksQ0FBQyxjQUFjLENBQUM7SUFDN0IsQ0FBQztJQUVEOzs7OztPQUtHO0lBQ0gsZ0JBQWdCO1FBQ2QsT0FBTyxJQUFJLENBQUMsc0JBQXNCLEVBQUUsQ0FBQztJQUN2QyxDQUFDO0NBQ0Y7QUFsS0Qsd0RBa0tDIn0=
|
|
@@ -15,9 +15,11 @@
|
|
|
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';
|
|
22
|
+
import { ILogger } from '../client/Logger';
|
|
21
23
|
/**
|
|
22
24
|
* Standard consume service for lite push consumer.
|
|
23
25
|
*
|
|
@@ -27,6 +29,6 @@ import type { ProcessQueue } from './ProcessQueue';
|
|
|
27
29
|
*/
|
|
28
30
|
export declare class LiteStandardConsumeService extends ConsumeService {
|
|
29
31
|
#private;
|
|
30
|
-
constructor(clientId: string, messageListener: MessageListener);
|
|
32
|
+
constructor(clientId: string, messageListener: MessageListener, messageInterceptor?: MessageInterceptor, consumerGroup?: string, logger?: ILogger);
|
|
31
33
|
consume(pq: ProcessQueue, messageViews: MessageView[]): void;
|
|
32
34
|
}
|
|
@@ -28,9 +28,9 @@ 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);
|
|
33
|
-
this.#logger = (0, Logger_1.getDefaultLogger)();
|
|
31
|
+
constructor(clientId, messageListener, messageInterceptor, consumerGroup, logger) {
|
|
32
|
+
super(clientId, messageListener, messageInterceptor, consumerGroup);
|
|
33
|
+
this.#logger = logger ?? (0, Logger_1.getDefaultLogger)();
|
|
34
34
|
}
|
|
35
35
|
consume(pq, messageViews) {
|
|
36
36
|
if (!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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTGl0ZVN0YW5kYXJkQ29uc3VtZVNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uc3VtZXIvTGl0ZVN0YW5kYXJkQ29uc3VtZVN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