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,563 @@
|
|
|
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
|
+
|
|
18
|
+
import { ClientType, MessageType, Permission } from '../../proto/apache/rocketmq/v2/definition_pb';
|
|
19
|
+
import {
|
|
20
|
+
AckMessageRequest,
|
|
21
|
+
ChangeInvisibleDurationRequest,
|
|
22
|
+
ForwardMessageToDeadLetterQueueRequest,
|
|
23
|
+
HeartbeatRequest,
|
|
24
|
+
NotifyClientTerminationRequest,
|
|
25
|
+
QueryAssignmentRequest,
|
|
26
|
+
ReceiveMessageRequest,
|
|
27
|
+
} from '../../proto/apache/rocketmq/v2/service_pb';
|
|
28
|
+
import { MessageView } from '../message';
|
|
29
|
+
import { Broker, MessageQueue, TopicRouteData } from '../route';
|
|
30
|
+
import { MessageQueue as MessageQueuePB, Broker as BrokerPB } from '../../proto/apache/rocketmq/v2/definition_pb';
|
|
31
|
+
import { StatusChecker } from '../exception';
|
|
32
|
+
import { RetryPolicy } from '../retry';
|
|
33
|
+
import { createDuration, createResource } from '../util';
|
|
34
|
+
import { Consumer, ConsumerOptions } from './Consumer';
|
|
35
|
+
import { FilterExpression } from './FilterExpression';
|
|
36
|
+
import { PushSubscriptionSettings } from './PushSubscriptionSettings';
|
|
37
|
+
import { ConsumeService } from './ConsumeService';
|
|
38
|
+
import { StandardConsumeService } from './StandardConsumeService';
|
|
39
|
+
import { FifoConsumeService } from './FifoConsumeService';
|
|
40
|
+
import { ProcessQueue } from './ProcessQueue';
|
|
41
|
+
import { Assignment } from './Assignment';
|
|
42
|
+
import { Assignments } from './Assignments';
|
|
43
|
+
import { MessageListener } from './MessageListener';
|
|
44
|
+
|
|
45
|
+
const ASSIGNMENT_SCAN_SCHEDULE_DELAY = 1000;
|
|
46
|
+
const ASSIGNMENT_SCAN_SCHEDULE_PERIOD = 5000;
|
|
47
|
+
|
|
48
|
+
export interface PushConsumerOptions extends ConsumerOptions {
|
|
49
|
+
subscriptions: Map<string/* topic */, FilterExpression | string>;
|
|
50
|
+
messageListener: MessageListener;
|
|
51
|
+
maxCacheMessageCount?: number;
|
|
52
|
+
maxCacheMessageSizeInBytes?: number;
|
|
53
|
+
longPollingTimeout?: number;
|
|
54
|
+
enableFifoConsumeAccelerator?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class ConsumeMetrics {
|
|
58
|
+
receptionTimes = 0;
|
|
59
|
+
receivedMessagesQuantity = 0;
|
|
60
|
+
consumptionOkQuantity = 0;
|
|
61
|
+
consumptionErrorQuantity = 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class PushConsumer extends Consumer {
|
|
65
|
+
readonly #pushSubscriptionSettings: PushSubscriptionSettings;
|
|
66
|
+
readonly #subscriptionExpressions = new Map<string, FilterExpression>();
|
|
67
|
+
readonly #cacheAssignments = new Map<string, Assignments>();
|
|
68
|
+
readonly #messageListener: MessageListener;
|
|
69
|
+
readonly #maxCacheMessageCount: number;
|
|
70
|
+
readonly #maxCacheMessageSizeInBytes: number;
|
|
71
|
+
readonly #enableFifoConsumeAccelerator: boolean;
|
|
72
|
+
readonly #processQueueTable = new Map<string /* mq key */, { mq: MessageQueue; pq: ProcessQueue }>();
|
|
73
|
+
readonly #metrics = new ConsumeMetrics();
|
|
74
|
+
#consumeService!: ConsumeService;
|
|
75
|
+
#scanAssignmentTimer?: NodeJS.Timeout;
|
|
76
|
+
|
|
77
|
+
constructor(options: PushConsumerOptions) {
|
|
78
|
+
options.topics = Array.from(options.subscriptions.keys());
|
|
79
|
+
super(options);
|
|
80
|
+
|
|
81
|
+
for (const [ topic, filter ] of options.subscriptions.entries()) {
|
|
82
|
+
if (typeof filter === 'string') {
|
|
83
|
+
this.#subscriptionExpressions.set(topic, new FilterExpression(filter));
|
|
84
|
+
} else {
|
|
85
|
+
this.#subscriptionExpressions.set(topic, filter);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.#messageListener = options.messageListener;
|
|
90
|
+
this.#maxCacheMessageCount = options.maxCacheMessageCount ?? 1024;
|
|
91
|
+
this.#maxCacheMessageSizeInBytes = options.maxCacheMessageSizeInBytes ?? 64 * 1024 * 1024;
|
|
92
|
+
this.#enableFifoConsumeAccelerator = options.enableFifoConsumeAccelerator ?? false;
|
|
93
|
+
|
|
94
|
+
this.#pushSubscriptionSettings = new PushSubscriptionSettings(
|
|
95
|
+
options.namespace, this.clientId, this.getClientType(), this.endpoints,
|
|
96
|
+
this.consumerGroup, this.requestTimeout, this.#subscriptionExpressions,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async startup() {
|
|
101
|
+
this.logger.info('Begin to start the rocketmq push consumer, clientId=%s, consumerGroup=%s',
|
|
102
|
+
this.clientId, this.consumerGroup);
|
|
103
|
+
await super.startup();
|
|
104
|
+
this.logger.info('Super startup completed, clientId=%s', this.clientId);
|
|
105
|
+
try {
|
|
106
|
+
this.#consumeService = this.#createConsumeService();
|
|
107
|
+
// Start scanning assignments periodically
|
|
108
|
+
this.startAssignmentScanning();
|
|
109
|
+
this.logger.info('Push consumer started successfully, clientId=%s', this.clientId);
|
|
110
|
+
} catch (err) {
|
|
111
|
+
this.logger.error('Failed to start push consumer, cleaning up resources, clientId=%s, error=%s',
|
|
112
|
+
this.clientId, err);
|
|
113
|
+
// Clean up timers if initialization fails
|
|
114
|
+
if (this.#scanAssignmentTimer) {
|
|
115
|
+
clearInterval(this.#scanAssignmentTimer);
|
|
116
|
+
this.#scanAssignmentTimer = undefined;
|
|
117
|
+
}
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Start assignment scanning. Can be overridden by subclasses.
|
|
124
|
+
*/
|
|
125
|
+
protected startAssignmentScanning() {
|
|
126
|
+
this.logger.info('Starting assignment scanning, clientId=%s', this.clientId);
|
|
127
|
+
setTimeout(() => this.#scanAssignments(), ASSIGNMENT_SCAN_SCHEDULE_DELAY);
|
|
128
|
+
this.#scanAssignmentTimer = setInterval(() => this.#scanAssignments(), ASSIGNMENT_SCAN_SCHEDULE_PERIOD);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async shutdown() {
|
|
132
|
+
this.logger.info('Begin to shutdown the rocketmq push consumer, clientId=%s', this.clientId);
|
|
133
|
+
// Stop scanning assignments
|
|
134
|
+
if (this.#scanAssignmentTimer) {
|
|
135
|
+
clearInterval(this.#scanAssignmentTimer);
|
|
136
|
+
this.#scanAssignmentTimer = undefined;
|
|
137
|
+
}
|
|
138
|
+
// Drop all process queues
|
|
139
|
+
this.logger.info('Dropping all process queues, clientId=%s, queueCount=%d',
|
|
140
|
+
this.clientId, this.#processQueueTable.size);
|
|
141
|
+
for (const { pq } of this.#processQueueTable.values()) {
|
|
142
|
+
pq.drop();
|
|
143
|
+
pq.abort();
|
|
144
|
+
}
|
|
145
|
+
this.#processQueueTable.clear();
|
|
146
|
+
// Shutdown consume service
|
|
147
|
+
if (this.#consumeService) {
|
|
148
|
+
this.logger.info('Shutting down consume service, clientId=%s', this.clientId);
|
|
149
|
+
this.#consumeService.abort();
|
|
150
|
+
}
|
|
151
|
+
await super.shutdown();
|
|
152
|
+
this.logger.info('Push consumer has been shutdown successfully, clientId=%s', this.clientId);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
protected getSettings() {
|
|
156
|
+
return this.#pushSubscriptionSettings;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Get the client type for push consumer.
|
|
161
|
+
*
|
|
162
|
+
* @return The client type identifier
|
|
163
|
+
*/
|
|
164
|
+
protected getClientType(): ClientType {
|
|
165
|
+
return ClientType.PUSH_CONSUMER;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
protected wrapHeartbeatRequest() {
|
|
169
|
+
return new HeartbeatRequest()
|
|
170
|
+
.setClientType(this.getClientType())
|
|
171
|
+
.setGroup(createResource(this.consumerGroup));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
protected wrapNotifyClientTerminationRequest() {
|
|
175
|
+
return new NotifyClientTerminationRequest()
|
|
176
|
+
.setGroup(createResource(this.consumerGroup));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
180
|
+
protected onTopicRouteDataUpdate(_topic: string, _topicRouteData: TopicRouteData) {
|
|
181
|
+
// No-op for push consumer; assignments are queried separately
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#createConsumeService(): ConsumeService {
|
|
185
|
+
if (this.#pushSubscriptionSettings.isFifo()) {
|
|
186
|
+
return new FifoConsumeService(this.clientId, this.#messageListener, this.#enableFifoConsumeAccelerator);
|
|
187
|
+
}
|
|
188
|
+
return new StandardConsumeService(this.clientId, this.#messageListener);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async subscribe(topic: string, filterExpression: FilterExpression) {
|
|
192
|
+
await this.getRouteData(topic);
|
|
193
|
+
this.#subscriptionExpressions.set(topic, filterExpression);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
unsubscribe(topic: string) {
|
|
197
|
+
this.#subscriptionExpressions.delete(topic);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// --- Public methods for ProcessQueue access ---
|
|
201
|
+
|
|
202
|
+
get requestTimeoutValue(): number {
|
|
203
|
+
return this.requestTimeout;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
getPushConsumerSettings(): PushSubscriptionSettings {
|
|
207
|
+
return this.#pushSubscriptionSettings;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
getConsumerGroup(): string {
|
|
211
|
+
return this.consumerGroup;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
getConsumeService(): ConsumeService {
|
|
215
|
+
return this.#consumeService;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
getRetryPolicy(): RetryPolicy | undefined {
|
|
219
|
+
return this.#pushSubscriptionSettings.getRetryPolicy();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
getClientId(): string {
|
|
223
|
+
return this.clientId;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// --- Metrics access ---
|
|
227
|
+
|
|
228
|
+
getReceptionTimes(): number {
|
|
229
|
+
return this.#metrics.receptionTimes;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
getReceivedMessagesQuantity(): number {
|
|
233
|
+
return this.#metrics.receivedMessagesQuantity;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
getConsumptionOkQuantity(): number {
|
|
237
|
+
return this.#metrics.consumptionOkQuantity;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
getConsumptionErrorQuantity(): number {
|
|
241
|
+
return this.#metrics.consumptionErrorQuantity;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
incrementReceptionTimes() {
|
|
245
|
+
this.#metrics.receptionTimes++;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
incrementReceivedMessagesQuantity(count: number) {
|
|
249
|
+
this.#metrics.receivedMessagesQuantity += count;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
incrementConsumptionOkQuantity() {
|
|
253
|
+
this.#metrics.consumptionOkQuantity++;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
incrementConsumptionErrorQuantity() {
|
|
257
|
+
this.#metrics.consumptionErrorQuantity++;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// --- Statistics ---
|
|
261
|
+
|
|
262
|
+
doStats() {
|
|
263
|
+
const receptionTimes = this.#metrics.receptionTimes;
|
|
264
|
+
this.#metrics.receptionTimes = 0;
|
|
265
|
+
const receivedMessagesQuantity = this.#metrics.receivedMessagesQuantity;
|
|
266
|
+
this.#metrics.receivedMessagesQuantity = 0;
|
|
267
|
+
const consumptionOkQuantity = this.#metrics.consumptionOkQuantity;
|
|
268
|
+
this.#metrics.consumptionOkQuantity = 0;
|
|
269
|
+
const consumptionErrorQuantity = this.#metrics.consumptionErrorQuantity;
|
|
270
|
+
this.#metrics.consumptionErrorQuantity = 0;
|
|
271
|
+
|
|
272
|
+
this.logger.info('clientId=%s, consumerGroup=%s, receptionTimes=%d, receivedMessagesQuantity=%d, '
|
|
273
|
+
+ 'consumptionOkQuantity=%d, consumptionErrorQuantity=%d',
|
|
274
|
+
this.clientId, this.consumerGroup, receptionTimes, receivedMessagesQuantity,
|
|
275
|
+
consumptionOkQuantity, consumptionErrorQuantity);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
wrapPushReceiveMessageRequest(
|
|
279
|
+
batchSize: number,
|
|
280
|
+
mq: MessageQueue,
|
|
281
|
+
filterExpression: FilterExpression,
|
|
282
|
+
longPollingTimeout: number,
|
|
283
|
+
attemptId?: string,
|
|
284
|
+
) {
|
|
285
|
+
const request = new ReceiveMessageRequest()
|
|
286
|
+
.setGroup(createResource(this.consumerGroup))
|
|
287
|
+
.setMessageQueue(mq.toProtobuf())
|
|
288
|
+
.setFilterExpression(filterExpression.toProtobuf())
|
|
289
|
+
.setLongPollingTimeout(createDuration(longPollingTimeout))
|
|
290
|
+
.setBatchSize(batchSize)
|
|
291
|
+
.setAutoRenew(true);
|
|
292
|
+
if (attemptId) {
|
|
293
|
+
request.setAttemptId(attemptId);
|
|
294
|
+
}
|
|
295
|
+
return request;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async receiveMessage(request: ReceiveMessageRequest, mq: MessageQueue, awaitDuration: number) {
|
|
299
|
+
return super.receiveMessage(request, mq, awaitDuration);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
wrapAckMessageRequest(messageView: MessageView) {
|
|
303
|
+
const request = new AckMessageRequest()
|
|
304
|
+
.setGroup(createResource(this.consumerGroup))
|
|
305
|
+
.setTopic(createResource(messageView.topic));
|
|
306
|
+
const entry = request.addEntries()
|
|
307
|
+
.setMessageId(messageView.messageId)
|
|
308
|
+
.setReceiptHandle(messageView.receiptHandle);
|
|
309
|
+
|
|
310
|
+
// For lite consumers, must set liteTopic in ACK request
|
|
311
|
+
if (this.isLiteConsumer() && messageView.liteTopic) {
|
|
312
|
+
entry.setLiteTopic(messageView.liteTopic);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return request;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
wrapChangeInvisibleDurationRequest(messageView: MessageView, invisibleDuration: number) {
|
|
319
|
+
const request = new ChangeInvisibleDurationRequest()
|
|
320
|
+
.setGroup(createResource(this.consumerGroup))
|
|
321
|
+
.setTopic(createResource(messageView.topic))
|
|
322
|
+
.setReceiptHandle(messageView.receiptHandle)
|
|
323
|
+
.setInvisibleDuration(createDuration(invisibleDuration))
|
|
324
|
+
.setMessageId(messageView.messageId);
|
|
325
|
+
|
|
326
|
+
// For lite consumers, must set liteTopic in request
|
|
327
|
+
if (this.isLiteConsumer() && messageView.liteTopic) {
|
|
328
|
+
request.setLiteTopic(messageView.liteTopic);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return request;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
wrapForwardMessageToDeadLetterQueueRequest(messageView: MessageView) {
|
|
335
|
+
const retryPolicy = this.getRetryPolicy();
|
|
336
|
+
const request = new ForwardMessageToDeadLetterQueueRequest()
|
|
337
|
+
.setGroup(createResource(this.consumerGroup))
|
|
338
|
+
.setTopic(createResource(messageView.topic))
|
|
339
|
+
.setReceiptHandle(messageView.receiptHandle)
|
|
340
|
+
.setMessageId(messageView.messageId)
|
|
341
|
+
.setDeliveryAttempt(messageView.deliveryAttempt ?? 0)
|
|
342
|
+
.setMaxDeliveryAttempts(retryPolicy?.getMaxAttempts() ?? 1);
|
|
343
|
+
|
|
344
|
+
// For lite consumers, must set liteTopic in request
|
|
345
|
+
if (this.isLiteConsumer() && messageView.liteTopic) {
|
|
346
|
+
request.setLiteTopic(messageView.liteTopic);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return request;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// --- Internal: queue size and cache threshold ---
|
|
353
|
+
|
|
354
|
+
getQueueSize(): number {
|
|
355
|
+
return this.#processQueueTable.size;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
cacheMessageBytesThresholdPerQueue(): number {
|
|
359
|
+
const size = this.getQueueSize();
|
|
360
|
+
if (size <= 0) return 0;
|
|
361
|
+
return Math.max(1, Math.floor(this.#maxCacheMessageSizeInBytes / size));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
cacheMessageCountThresholdPerQueue(): number {
|
|
365
|
+
const size = this.getQueueSize();
|
|
366
|
+
if (size <= 0) return 0;
|
|
367
|
+
return Math.max(1, Math.floor(this.#maxCacheMessageCount / size));
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// --- Internal: assignment scanning ---
|
|
371
|
+
|
|
372
|
+
#scanAssignments() {
|
|
373
|
+
try {
|
|
374
|
+
this.logger.debug?.('Scanning assignments, clientId=%s, subscriptionCount=%d',
|
|
375
|
+
this.clientId, this.#subscriptionExpressions.size);
|
|
376
|
+
for (const [ topic, filterExpression ] of this.#subscriptionExpressions) {
|
|
377
|
+
const existed = this.#cacheAssignments.get(topic);
|
|
378
|
+
this.#queryAssignment(topic)
|
|
379
|
+
.then(latest => {
|
|
380
|
+
this.logger.debug?.('Query assignment result, topic=%s, clientId=%s, assignmentCount=%d',
|
|
381
|
+
topic, this.clientId, latest.getAssignmentList().length);
|
|
382
|
+
if (latest.getAssignmentList().length === 0) {
|
|
383
|
+
if (!existed || existed.getAssignmentList().length === 0) {
|
|
384
|
+
this.logger.info('Acquired empty assignments from remote, would scan later, topic=%s, '
|
|
385
|
+
+ 'clientId=%s', topic, this.clientId);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
this.logger.warn('Attention!!! acquired empty assignments from remote, but existed assignments'
|
|
389
|
+
+ ' is not empty, topic=%s, clientId=%s', topic, this.clientId);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (!latest.equals(existed)) {
|
|
393
|
+
this.logger.info('Assignments of topic=%s has changed, %j => %j, clientId=%s', topic, existed,
|
|
394
|
+
latest, this.clientId);
|
|
395
|
+
this.#syncProcessQueue(topic, latest, filterExpression);
|
|
396
|
+
this.#cacheAssignments.set(topic, latest);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
this.logger.debug?.('Assignments of topic=%s remains the same, assignments=%j, clientId=%s', topic,
|
|
400
|
+
existed, this.clientId);
|
|
401
|
+
// Process queue may be dropped, need to be synchronized anyway.
|
|
402
|
+
this.#syncProcessQueue(topic, latest, filterExpression);
|
|
403
|
+
})
|
|
404
|
+
.catch(err => {
|
|
405
|
+
this.logger.error('Exception raised while scanning the assignments, topic=%s, clientId=%s, error=%s',
|
|
406
|
+
topic, this.clientId, err);
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
} catch (err) {
|
|
410
|
+
this.logger.error('Exception raised while scanning the assignments for all topics, clientId=%s, error=%s',
|
|
411
|
+
this.clientId, err);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
async #queryAssignment(topic: string): Promise<Assignments> {
|
|
416
|
+
const topicRouteData = await this.getRouteData(topic);
|
|
417
|
+
const endpointsList = topicRouteData.getTotalEndpoints();
|
|
418
|
+
if (endpointsList.length === 0) {
|
|
419
|
+
throw new Error(`No endpoints available for topic=${topic}`);
|
|
420
|
+
}
|
|
421
|
+
const endpoints = endpointsList[0];
|
|
422
|
+
|
|
423
|
+
const request = new QueryAssignmentRequest()
|
|
424
|
+
.setTopic(createResource(topic))
|
|
425
|
+
.setGroup(createResource(this.consumerGroup))
|
|
426
|
+
.setEndpoints(this.endpoints.toProtobuf());
|
|
427
|
+
|
|
428
|
+
const response = await this.rpcClientManager.queryAssignment(
|
|
429
|
+
endpoints, request, this.requestTimeout,
|
|
430
|
+
);
|
|
431
|
+
const status = response.getStatus();
|
|
432
|
+
if (!status) {
|
|
433
|
+
throw new Error('Missing status in query assignment response');
|
|
434
|
+
}
|
|
435
|
+
StatusChecker.check(status.toObject());
|
|
436
|
+
|
|
437
|
+
const assignmentList = response.getAssignmentsList().map(assignment => {
|
|
438
|
+
const mqPb = assignment.getMessageQueue()!;
|
|
439
|
+
const mq = new MessageQueue(mqPb);
|
|
440
|
+
return new Assignment(mq);
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
return new Assignments(assignmentList);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
#syncProcessQueue(topic: string, assignments: Assignments, filterExpression: FilterExpression) {
|
|
447
|
+
const latestMqKeys = new Set<string>();
|
|
448
|
+
for (const assignment of assignments.getAssignmentList()) {
|
|
449
|
+
latestMqKeys.add(this.#mqKey(assignment.messageQueue));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// Find active message queues
|
|
453
|
+
const activeMqKeys = new Set<string>();
|
|
454
|
+
for (const [ mqKey, { mq, pq }] of this.#processQueueTable) {
|
|
455
|
+
if (mq.topic.name !== topic) {
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
if (!latestMqKeys.has(mqKey)) {
|
|
459
|
+
this.logger.info('Drop message queue according to the latest assignmentList, mq=%s@%s@%s, clientId=%s',
|
|
460
|
+
mq.topic.name, mq.broker.name, mq.queueId, this.clientId);
|
|
461
|
+
this.#dropProcessQueue(mqKey);
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
if (pq.expired()) {
|
|
465
|
+
this.logger.warn('Drop message queue because it is expired, mq=%s@%s@%s, clientId=%s',
|
|
466
|
+
mq.topic.name, mq.broker.name, mq.queueId, this.clientId);
|
|
467
|
+
this.#dropProcessQueue(mqKey);
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
activeMqKeys.add(mqKey);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// Create new process queues for new assignments
|
|
474
|
+
for (const assignment of assignments.getAssignmentList()) {
|
|
475
|
+
const mqKey = this.#mqKey(assignment.messageQueue);
|
|
476
|
+
if (activeMqKeys.has(mqKey)) {
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
const processQueue = this.#createProcessQueue(assignment.messageQueue, filterExpression);
|
|
480
|
+
if (processQueue) {
|
|
481
|
+
this.logger.info('Start to fetch message from remote, mq=%s@%s@%s, clientId=%s',
|
|
482
|
+
assignment.messageQueue.topic.name, assignment.messageQueue.broker.name,
|
|
483
|
+
assignment.messageQueue.queueId, this.clientId);
|
|
484
|
+
processQueue.fetchMessageImmediately();
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
#mqKey(mq: MessageQueue): string {
|
|
490
|
+
return `${mq.topic.name}@${mq.broker.name}@${mq.queueId}`;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
#dropProcessQueue(mqKey: string) {
|
|
494
|
+
const entry = this.#processQueueTable.get(mqKey);
|
|
495
|
+
if (entry) {
|
|
496
|
+
entry.pq.drop();
|
|
497
|
+
this.#processQueueTable.delete(mqKey);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
#createProcessQueue(mq: MessageQueue, filterExpression: FilterExpression): ProcessQueue | null {
|
|
502
|
+
const mqKey = this.#mqKey(mq);
|
|
503
|
+
if (this.#processQueueTable.has(mqKey)) {
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
506
|
+
const processQueue = new ProcessQueue(this, mq, filterExpression);
|
|
507
|
+
this.#processQueueTable.set(mqKey, { mq, pq: processQueue });
|
|
508
|
+
return processQueue;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Create a virtual process queue for Lite consumer.
|
|
513
|
+
* Lite consumers use a special message queue with queueId=-1 to receive messages.
|
|
514
|
+
* This method creates the virtual queue and starts fetching messages immediately.
|
|
515
|
+
*
|
|
516
|
+
* @param topic - The bind topic name
|
|
517
|
+
* @param filterExpression - The filter expression for message filtering
|
|
518
|
+
*/
|
|
519
|
+
protected createVirtualProcessQueueForLite(topic: string, filterExpression: FilterExpression) {
|
|
520
|
+
// Validate parameters
|
|
521
|
+
if (!topic || topic.trim().length === 0) {
|
|
522
|
+
throw new Error('topic should not be blank');
|
|
523
|
+
}
|
|
524
|
+
if (!filterExpression) {
|
|
525
|
+
throw new Error('filterExpression should not be null');
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// Create a virtual broker with default endpoints
|
|
529
|
+
const brokerPb = new BrokerPB();
|
|
530
|
+
brokerPb.setName('virtual-broker');
|
|
531
|
+
brokerPb.setId(0);
|
|
532
|
+
brokerPb.setEndpoints(this.endpoints.toProtobuf());
|
|
533
|
+
const broker = new Broker(brokerPb.toObject());
|
|
534
|
+
|
|
535
|
+
// Create a virtual message queue with queueId=-1
|
|
536
|
+
const virtualMqPb = new MessageQueuePB();
|
|
537
|
+
virtualMqPb.setId(-1); // Virtual queue ID for Lite consumer
|
|
538
|
+
virtualMqPb.setTopic(createResource(topic));
|
|
539
|
+
virtualMqPb.setBroker(broker.toProtobuf());
|
|
540
|
+
virtualMqPb.setPermission(Permission.READ);
|
|
541
|
+
virtualMqPb.setAcceptMessageTypesList([ MessageType.LITE ]);
|
|
542
|
+
|
|
543
|
+
const virtualMq = new MessageQueue(virtualMqPb);
|
|
544
|
+
|
|
545
|
+
// Create process queue for the virtual message queue
|
|
546
|
+
const mqKey = this.#mqKey(virtualMq);
|
|
547
|
+
if (this.#processQueueTable.has(mqKey)) {
|
|
548
|
+
this.logger.info('Virtual process queue already exists, mq=%s, clientId=%s', mqKey, this.clientId);
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
const processQueue = new ProcessQueue(this, virtualMq, filterExpression);
|
|
553
|
+
this.#processQueueTable.set(mqKey, { mq: virtualMq, pq: processQueue });
|
|
554
|
+
|
|
555
|
+
this.logger.info('Created virtual process queue for Lite consumer, mq=%s, clientId=%s',
|
|
556
|
+
mqKey, this.clientId);
|
|
557
|
+
|
|
558
|
+
// Start fetching messages immediately
|
|
559
|
+
this.logger.info('Start to fetch lite messages from virtual queue, mq=%s, clientId=%s',
|
|
560
|
+
mqKey, this.clientId);
|
|
561
|
+
processQueue.fetchMessageImmediately();
|
|
562
|
+
}
|
|
563
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
|
|
18
|
+
import {
|
|
19
|
+
Settings as SettingsPB,
|
|
20
|
+
ClientType,
|
|
21
|
+
Subscription,
|
|
22
|
+
RetryPolicy as RetryPolicyPB,
|
|
23
|
+
} from '../../proto/apache/rocketmq/v2/definition_pb';
|
|
24
|
+
import { Endpoints } from '../route';
|
|
25
|
+
import { Settings, UserAgent } from '../client';
|
|
26
|
+
import { ExponentialBackoffRetryPolicy, RetryPolicy } from '../retry';
|
|
27
|
+
import { createDuration, createResource } from '../util';
|
|
28
|
+
import { FilterExpression } from './FilterExpression';
|
|
29
|
+
|
|
30
|
+
export class PushSubscriptionSettings extends Settings {
|
|
31
|
+
readonly #group: string;
|
|
32
|
+
readonly #subscriptionExpressions: Map<string, FilterExpression>;
|
|
33
|
+
#fifo = false;
|
|
34
|
+
#receiveBatchSize = 32;
|
|
35
|
+
#longPollingTimeout = 30000; // ms
|
|
36
|
+
|
|
37
|
+
constructor(
|
|
38
|
+
namespace: string,
|
|
39
|
+
clientId: string,
|
|
40
|
+
clientType: ClientType,
|
|
41
|
+
accessPoint: Endpoints,
|
|
42
|
+
consumerGroup: string,
|
|
43
|
+
requestTimeout: number,
|
|
44
|
+
subscriptionExpressions: Map<string, FilterExpression>,
|
|
45
|
+
longPollingTimeout?: number,
|
|
46
|
+
) {
|
|
47
|
+
super(namespace, clientId, clientType, accessPoint, requestTimeout);
|
|
48
|
+
this.#group = consumerGroup;
|
|
49
|
+
this.#subscriptionExpressions = subscriptionExpressions;
|
|
50
|
+
if (longPollingTimeout !== undefined) {
|
|
51
|
+
this.#longPollingTimeout = longPollingTimeout;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
isFifo(): boolean {
|
|
56
|
+
return this.#fifo;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getReceiveBatchSize(): number {
|
|
60
|
+
return this.#receiveBatchSize;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getLongPollingTimeout(): number {
|
|
64
|
+
return this.#longPollingTimeout;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getRetryPolicy(): RetryPolicy | undefined {
|
|
68
|
+
return this.retryPolicy;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
toProtobuf(): SettingsPB {
|
|
72
|
+
const subscription = new Subscription()
|
|
73
|
+
.setGroup(createResource(this.#group));
|
|
74
|
+
|
|
75
|
+
for (const [ topic, filterExpression ] of this.#subscriptionExpressions.entries()) {
|
|
76
|
+
subscription.addSubscriptions()
|
|
77
|
+
.setTopic(createResource(topic))
|
|
78
|
+
.setExpression(filterExpression.toProtobuf());
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return new SettingsPB()
|
|
82
|
+
.setClientType(this.clientType)
|
|
83
|
+
.setAccessPoint(this.accessPoint.toProtobuf())
|
|
84
|
+
.setRequestTimeout(createDuration(this.requestTimeout))
|
|
85
|
+
.setSubscription(subscription)
|
|
86
|
+
.setUserAgent(UserAgent.INSTANCE.toProtobuf());
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
sync(settings: SettingsPB): void {
|
|
90
|
+
if (settings.getPubSubCase() !== SettingsPB.PubSubCase.SUBSCRIPTION) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const subscription = settings.getSubscription();
|
|
94
|
+
if (subscription) {
|
|
95
|
+
this.#fifo = subscription.getFifo() ?? false;
|
|
96
|
+
this.#receiveBatchSize = subscription.getReceiveBatchSize() ?? 32;
|
|
97
|
+
const longPollingTimeout = subscription.getLongPollingTimeout();
|
|
98
|
+
if (longPollingTimeout) {
|
|
99
|
+
this.#longPollingTimeout = longPollingTimeout.getSeconds() * 1000 +
|
|
100
|
+
Math.floor(longPollingTimeout.getNanos() / 1000000);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const backoffPolicy = settings.getBackoffPolicy();
|
|
104
|
+
if (backoffPolicy) {
|
|
105
|
+
switch (backoffPolicy.getStrategyCase()) {
|
|
106
|
+
case RetryPolicyPB.StrategyCase.EXPONENTIAL_BACKOFF: {
|
|
107
|
+
const exponential = backoffPolicy.getExponentialBackoff()!.toObject();
|
|
108
|
+
this.retryPolicy = new ExponentialBackoffRetryPolicy(
|
|
109
|
+
backoffPolicy.getMaxAttempts(),
|
|
110
|
+
exponential.initial?.seconds,
|
|
111
|
+
exponential.max?.seconds,
|
|
112
|
+
exponential.multiplier,
|
|
113
|
+
);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case RetryPolicyPB.StrategyCase.CUSTOMIZED_BACKOFF:
|
|
117
|
+
// CustomizedBackoffRetryPolicy not yet implemented in Node.js
|
|
118
|
+
break;
|
|
119
|
+
default:
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|