rocketmq-client-nodejs 0.0.0 → 1.0.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/LICENSE +201 -0
- package/README.md +69 -1
- package/dist/client/BaseClient.d.ts +92 -0
- package/dist/client/BaseClient.js +308 -0
- package/dist/client/ClientId.d.ts +24 -0
- package/dist/client/ClientId.js +33 -0
- package/dist/client/Logger.d.ts +24 -0
- package/dist/client/Logger.js +34 -0
- package/dist/client/RpcClient.d.ts +47 -0
- package/dist/client/RpcClient.js +208 -0
- package/dist/client/RpcClientManager.d.ts +41 -0
- package/dist/client/RpcClientManager.js +139 -0
- package/dist/client/SessionCredentials.d.ts +21 -0
- package/dist/client/SessionCredentials.js +19 -0
- package/dist/client/Settings.d.ts +30 -0
- package/dist/client/Settings.js +38 -0
- package/dist/client/TelemetrySession.d.ts +27 -0
- package/dist/client/TelemetrySession.js +101 -0
- package/dist/client/UserAgent.d.ts +25 -0
- package/dist/client/UserAgent.js +47 -0
- package/dist/client/index.d.ts +26 -0
- package/dist/client/index.js +43 -0
- package/dist/consumer/Consumer.d.ts +32 -0
- package/dist/consumer/Consumer.js +96 -0
- package/dist/consumer/FilterExpression.d.ts +25 -0
- package/dist/consumer/FilterExpression.js +40 -0
- package/dist/consumer/SimpleConsumer.d.ts +47 -8
- package/dist/consumer/SimpleConsumer.js +105 -27
- package/dist/consumer/SimpleSubscriptionSettings.d.ts +28 -0
- package/dist/consumer/SimpleSubscriptionSettings.js +57 -0
- package/dist/consumer/SubscriptionLoadBalancer.d.ts +23 -0
- package/dist/consumer/SubscriptionLoadBalancer.js +46 -0
- package/dist/consumer/index.d.ts +21 -0
- package/dist/consumer/index.js +38 -0
- package/dist/exception/BadRequestException.d.ts +20 -0
- package/dist/exception/BadRequestException.js +28 -0
- package/dist/exception/ClientException.d.ts +20 -0
- package/dist/exception/ClientException.js +31 -0
- package/dist/exception/ForbiddenException.d.ts +20 -0
- package/dist/exception/ForbiddenException.js +28 -0
- package/dist/exception/InternalErrorException.d.ts +20 -0
- package/dist/exception/InternalErrorException.js +28 -0
- package/dist/exception/NotFoundException.d.ts +20 -0
- package/dist/exception/NotFoundException.js +28 -0
- package/dist/exception/PayloadTooLargeException.d.ts +20 -0
- package/dist/exception/PayloadTooLargeException.js +28 -0
- package/dist/exception/PaymentRequiredException.d.ts +20 -0
- package/dist/exception/PaymentRequiredException.js +28 -0
- package/dist/exception/ProxyTimeoutException.d.ts +20 -0
- package/dist/exception/ProxyTimeoutException.js +28 -0
- package/dist/exception/RequestHeaderFieldsTooLargeException.d.ts +20 -0
- package/dist/exception/RequestHeaderFieldsTooLargeException.js +28 -0
- package/dist/exception/StatusChecker.d.ts +20 -0
- package/dist/exception/StatusChecker.js +98 -0
- package/dist/exception/TooManyRequestsException.d.ts +20 -0
- package/dist/exception/TooManyRequestsException.js +28 -0
- package/dist/exception/UnauthorizedException.d.ts +20 -0
- package/dist/exception/UnauthorizedException.js +28 -0
- package/dist/exception/UnsupportedException.d.ts +20 -0
- package/dist/exception/UnsupportedException.js +28 -0
- package/dist/exception/index.d.ts +29 -0
- package/dist/exception/index.js +46 -0
- package/dist/index.d.ts +22 -3
- package/dist/index.js +23 -4
- package/dist/message/Message.d.ts +37 -0
- package/dist/message/Message.js +43 -0
- package/dist/message/MessageId.d.ts +59 -0
- package/dist/message/MessageId.js +123 -0
- package/dist/message/MessageView.d.ts +39 -0
- package/dist/message/MessageView.js +90 -0
- package/dist/message/PublishingMessage.d.ts +30 -0
- package/dist/message/PublishingMessage.js +98 -0
- package/dist/message/index.d.ts +20 -0
- package/dist/message/index.js +37 -0
- package/dist/producer/Producer.d.ts +42 -0
- package/dist/producer/Producer.js +242 -1
- package/dist/producer/PublishingLoadBalancer.d.ts +24 -0
- package/dist/producer/PublishingLoadBalancer.js +82 -0
- package/dist/producer/PublishingSettings.d.ts +28 -0
- package/dist/producer/PublishingSettings.js +70 -0
- package/dist/producer/SendReceipt.d.ts +28 -0
- package/dist/producer/SendReceipt.js +57 -0
- package/dist/producer/Transaction.d.ts +28 -0
- package/dist/producer/Transaction.js +64 -0
- package/dist/producer/TransactionChecker.d.ts +21 -0
- package/dist/producer/TransactionChecker.js +19 -0
- package/dist/producer/index.d.ts +21 -0
- package/dist/producer/index.js +39 -0
- package/dist/retry/ExponentialBackoffRetryPolicy.d.ts +27 -0
- package/dist/retry/ExponentialBackoffRetryPolicy.js +67 -0
- package/dist/retry/RetryPolicy.d.ts +46 -0
- package/dist/retry/RetryPolicy.js +19 -0
- package/dist/retry/index.d.ts +18 -0
- package/dist/retry/index.js +35 -0
- package/dist/route/Broker.d.ts +25 -0
- package/dist/route/Broker.js +40 -0
- package/dist/route/Endpoints.d.ts +30 -0
- package/dist/route/Endpoints.js +71 -0
- package/dist/route/MessageQueue.d.ts +27 -0
- package/dist/route/MessageQueue.js +47 -0
- package/dist/route/TopicRouteData.d.ts +24 -0
- package/dist/route/TopicRouteData.js +37 -0
- package/dist/route/index.d.ts +20 -0
- package/dist/route/index.js +37 -0
- package/dist/util/index.d.ts +36 -0
- package/dist/util/index.js +88 -0
- package/package.json +12 -5
- package/src/client/BaseClient.ts +384 -0
- package/src/client/ClientId.ts +31 -0
- package/src/client/Logger.ts +35 -0
- package/src/client/RpcClient.ts +245 -0
- package/src/client/RpcClientManager.ts +173 -0
- package/src/client/SessionCredentials.ts +22 -0
- package/src/client/Settings.ts +45 -0
- package/src/client/TelemetrySession.ts +118 -0
- package/src/client/UserAgent.ts +45 -0
- package/src/client/index.ts +27 -0
- package/src/consumer/Consumer.ts +111 -0
- package/src/consumer/FilterExpression.ts +42 -0
- package/src/consumer/SimpleConsumer.ts +133 -20
- package/src/consumer/SimpleSubscriptionSettings.ts +65 -0
- package/src/consumer/SubscriptionLoadBalancer.ts +47 -0
- package/src/consumer/index.ts +22 -0
- package/src/exception/BadRequestException.ts +25 -0
- package/src/exception/ClientException.ts +29 -0
- package/src/exception/ForbiddenException.ts +25 -0
- package/src/exception/InternalErrorException.ts +25 -0
- package/src/exception/NotFoundException.ts +25 -0
- package/src/exception/PayloadTooLargeException.ts +25 -0
- package/src/exception/PaymentRequiredException.ts +25 -0
- package/src/exception/ProxyTimeoutException.ts +25 -0
- package/src/exception/RequestHeaderFieldsTooLargeException.ts +25 -0
- package/src/exception/StatusChecker.ts +94 -0
- package/src/exception/TooManyRequestsException.ts +25 -0
- package/src/exception/UnauthorizedException.ts +25 -0
- package/src/exception/UnsupportedException.ts +25 -0
- package/src/exception/index.ts +30 -0
- package/src/index.ts +23 -3
- package/src/message/Message.ts +51 -0
- package/src/message/MessageId.ts +123 -0
- package/src/message/MessageView.ts +94 -0
- package/src/message/PublishingMessage.ts +102 -0
- package/src/message/index.ts +21 -0
- package/src/producer/Producer.ts +291 -0
- package/src/producer/PublishingLoadBalancer.ts +85 -0
- package/src/producer/PublishingSettings.ts +79 -0
- package/src/producer/SendReceipt.ts +60 -0
- package/src/producer/Transaction.ts +70 -0
- package/src/producer/TransactionChecker.ts +23 -0
- package/src/producer/index.ts +23 -0
- package/src/retry/ExponentialBackoffRetryPolicy.ts +76 -0
- package/src/retry/RetryPolicy.ts +51 -0
- package/src/retry/index.ts +19 -0
- package/src/route/Broker.ts +39 -0
- package/src/route/Endpoints.ts +70 -0
- package/src/route/MessageQueue.ts +49 -0
- package/src/route/TopicRouteData.ts +38 -0
- package/src/route/index.ts +21 -0
- package/src/util/index.ts +83 -0
- package/dist/grpc/MessagingServiceClient.d.ts +0 -9
- package/dist/grpc/MessagingServiceClient.js +0 -13
- package/dist/model/SessionCredentials.d.ts +0 -5
- package/dist/model/SessionCredentials.js +0 -3
- package/src/grpc/MessagingServiceClient.ts +0 -17
- package/src/model/SessionCredentials.ts +0 -5
|
@@ -0,0 +1,101 @@
|
|
|
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.TelemetrySession = void 0;
|
|
20
|
+
const service_pb_1 = require("../../proto/apache/rocketmq/v2/service_pb");
|
|
21
|
+
class TelemetrySession {
|
|
22
|
+
#endpoints;
|
|
23
|
+
#baseClient;
|
|
24
|
+
#logger;
|
|
25
|
+
#stream;
|
|
26
|
+
constructor(baseClient, endpoints, logger) {
|
|
27
|
+
this.#endpoints = endpoints;
|
|
28
|
+
this.#baseClient = baseClient;
|
|
29
|
+
this.#logger = logger;
|
|
30
|
+
this.#renewStream(true);
|
|
31
|
+
}
|
|
32
|
+
release() {
|
|
33
|
+
this.#logger.info('Begin to release telemetry session, endpoints=%s, clientId=%s', this.#endpoints, this.#baseClient.clientId);
|
|
34
|
+
this.#stream.end();
|
|
35
|
+
this.#stream.removeAllListeners();
|
|
36
|
+
}
|
|
37
|
+
write(command) {
|
|
38
|
+
this.#stream.write(command);
|
|
39
|
+
}
|
|
40
|
+
syncSettings() {
|
|
41
|
+
const command = this.#baseClient.settingsCommand();
|
|
42
|
+
this.write(command);
|
|
43
|
+
}
|
|
44
|
+
#renewStream(inited) {
|
|
45
|
+
this.#stream = this.#baseClient.createTelemetryStream(this.#endpoints);
|
|
46
|
+
this.#stream.on('data', this.#onData.bind(this));
|
|
47
|
+
this.#stream.once('error', this.#onError.bind(this));
|
|
48
|
+
this.#stream.once('end', this.#onEnd.bind(this));
|
|
49
|
+
if (!inited) {
|
|
50
|
+
this.syncSettings();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
#onData(command) {
|
|
54
|
+
const endpoints = this.#endpoints;
|
|
55
|
+
const clientId = this.#baseClient.clientId;
|
|
56
|
+
const commandCase = command.getCommandCase();
|
|
57
|
+
switch (commandCase) {
|
|
58
|
+
case service_pb_1.TelemetryCommand.CommandCase.SETTINGS:
|
|
59
|
+
this.#logger.info('Receive settings from remote, endpoints=%s, clientId=%s', endpoints, clientId);
|
|
60
|
+
this.#baseClient.onSettingsCommand(endpoints, command.getSettings());
|
|
61
|
+
break;
|
|
62
|
+
case service_pb_1.TelemetryCommand.CommandCase.RECOVER_ORPHANED_TRANSACTION_COMMAND: {
|
|
63
|
+
this.#logger.info('Receive orphaned transaction recovery command from remote, endpoints=%s, clientId=%s', endpoints, clientId);
|
|
64
|
+
this.#baseClient.onRecoverOrphanedTransactionCommand(endpoints, command.getRecoverOrphanedTransactionCommand());
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case service_pb_1.TelemetryCommand.CommandCase.VERIFY_MESSAGE_COMMAND: {
|
|
68
|
+
this.#logger.info('Receive message verification command from remote, endpoints=%s, clientId=%s', endpoints, clientId);
|
|
69
|
+
this.#baseClient.onVerifyMessageCommand(endpoints, command.getVerifyMessageCommand());
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case service_pb_1.TelemetryCommand.CommandCase.PRINT_THREAD_STACK_TRACE_COMMAND: {
|
|
73
|
+
this.#logger.info('Receive thread stack print command from remote, endpoints=%s, clientId=%s', endpoints, clientId);
|
|
74
|
+
this.#baseClient.onPrintThreadStackTraceCommand(endpoints, command.getPrintThreadStackTraceCommand());
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
default: {
|
|
78
|
+
const commandObj = command.toObject();
|
|
79
|
+
this.#logger.warn('Receive unrecognized command from remote, endpoints=%s, commandCase=%j, command=%j, clientId=%s', endpoints, commandCase, commandObj, clientId);
|
|
80
|
+
// should telemetry session start fail
|
|
81
|
+
this.#baseClient.onUnknownCommand(endpoints, commandObj.status);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
#onError(err) {
|
|
86
|
+
this.#logger.error('Exception raised from stream response observer, endpoints=%s, clientId=%s, error=%s', this.#endpoints, this.#baseClient.clientId, err);
|
|
87
|
+
this.release();
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
this.#renewStream(false);
|
|
90
|
+
}, 1000);
|
|
91
|
+
}
|
|
92
|
+
#onEnd() {
|
|
93
|
+
this.#logger.info('Receive completion for stream response observer, endpoints=%s, clientId=%s', this.#endpoints, this.#baseClient.clientId);
|
|
94
|
+
this.release();
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
this.#renewStream(false);
|
|
97
|
+
}, 1000);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.TelemetrySession = TelemetrySession;
|
|
101
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVGVsZW1ldHJ5U2Vzc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbGllbnQvVGVsZW1ldHJ5U2Vzc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHOzs7QUFHSCwwRUFBNkU7QUFLN0UsTUFBYSxnQkFBZ0I7SUFDM0IsVUFBVSxDQUFZO0lBQ3RCLFdBQVcsQ0FBYTtJQUN4QixPQUFPLENBQVU7SUFDakIsT0FBTyxDQUF5RDtJQUVoRSxZQUFZLFVBQXNCLEVBQUUsU0FBb0IsRUFBRSxNQUFlO1FBQ3ZFLElBQUksQ0FBQyxVQUFVLEdBQUcsU0FBUyxDQUFDO1FBQzVCLElBQUksQ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QUFDO1FBQ0gsQ0FBQztJQUNILENBQUM7SUFFRCxRQUFRLENBQUMsR0FBVTtRQUNqQixJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxxRkFBcUYsRUFDdEcsSUFBSSxDQUFDLFVBQVUsRUFBRSxJQUFJLENBQUMsV0FBVyxDQUFDLFFBQVEsRUFBRSxHQUFHLENBQUMsQ0FBQztRQUNuRCxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDZixVQUFVLENBQUMsR0FBRyxFQUFFO1lBQ2QsSUFBSSxDQUFDLFlBQVksQ0FBQyxLQUFLLENBQUMsQ0FBQztRQUMzQixDQUFDLEVBQUUsSUFBSSxDQUFDLENBQUM7SUFDWCxDQUFDO0lBRUQsTUFBTTtRQUNKLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLDRFQUE0RSxFQUM1RixJQUFJLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxXQUFXLENBQUMsUUFBUSxDQUFDLENBQUM7UUFDOUMsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO1FBQ2YsVUFBVSxDQUFDLEdBQUcsRUFBRTtZQUNkLElBQUksQ0FBQyxZQUFZLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDM0IsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFDO0lBQ1gsQ0FBQztDQUNGO0FBOUZELDRDQThGQyJ9
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { UA } from '../../proto/apache/rocketmq/v2/definition_pb';
|
|
18
|
+
export declare class UserAgent {
|
|
19
|
+
static readonly INSTANCE: UserAgent;
|
|
20
|
+
readonly version: string;
|
|
21
|
+
readonly platform: string;
|
|
22
|
+
readonly hostname: string;
|
|
23
|
+
constructor(version: string, platform: string, hostname: string);
|
|
24
|
+
toProtobuf(): UA;
|
|
25
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.UserAgent = void 0;
|
|
23
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
24
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
25
|
+
const node_fs_1 = require("node:fs");
|
|
26
|
+
const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
|
|
27
|
+
const VERSION = JSON.parse((0, node_fs_1.readFileSync)(node_path_1.default.join(__dirname, '../../package.json'), 'utf-8')).version;
|
|
28
|
+
class UserAgent {
|
|
29
|
+
static INSTANCE = new UserAgent(VERSION, node_os_1.default.platform(), node_os_1.default.hostname());
|
|
30
|
+
version;
|
|
31
|
+
platform;
|
|
32
|
+
hostname;
|
|
33
|
+
constructor(version, platform, hostname) {
|
|
34
|
+
this.version = version;
|
|
35
|
+
this.platform = platform;
|
|
36
|
+
this.hostname = hostname;
|
|
37
|
+
}
|
|
38
|
+
toProtobuf() {
|
|
39
|
+
return new definition_pb_1.UA()
|
|
40
|
+
.setLanguage(definition_pb_1.Language.NODE_JS)
|
|
41
|
+
.setVersion(this.version)
|
|
42
|
+
.setPlatform(this.platform)
|
|
43
|
+
.setHostname(this.hostname);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.UserAgent = UserAgent;
|
|
47
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVXNlckFnZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NsaWVudC9Vc2VyQWdlbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7Ozs7O0FBRUgsc0RBQXlCO0FBQ3pCLDBEQUE2QjtBQUM3QixxQ0FBdUM7QUFDdkMsZ0ZBQTRFO0FBRTVFLE1BQU0sT0FBTyxHQUFXLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBQSxzQkFBWSxFQUFDLG1CQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBRSxvQkFBb0IsQ0FBQyxFQUFFLE9BQU8sQ0FBQyxDQUFDLENBQUMsT0FBTyxDQUFDO0FBRTlHLE1BQWEsU0FBUztJQUNwQixNQUFNLENBQVUsUUFBUSxHQUFHLElBQUksU0FBUyxDQUFDLE9BQU8sRUFBRSxpQkFBRSxDQUFDLFFBQVEsRUFBRSxFQUFFLGlCQUFFLENBQUMsUUFBUSxFQUFFLENBQUMsQ0FBQztJQUV2RSxPQUFPLENBQVM7SUFDaEIsUUFBUSxDQUFTO0lBQ2pCLFFBQVEsQ0FBUztJQUUxQixZQUFZLE9BQWUsRUFBRSxRQUFnQixFQUFFLFFBQWdCO1FBQzdELElBQUksQ0FBQyxPQUFPLEdBQUcsT0FBTyxDQUFDO1FBQ3ZCLElBQUksQ0FBQyxRQUFRLEdBQUcsUUFBUSxDQUFDO1FBQ3pCLElBQUksQ0FBQyxRQUFRLEdBQUcsUUFBUSxDQUFDO0lBQzNCLENBQUM7SUFFRCxVQUFVO1FBQ1IsT0FBTyxJQUFJLGtCQUFFLEVBQUU7YUFDWixXQUFXLENBQUMsd0JBQVEsQ0FBQyxPQUFPLENBQUM7YUFDN0IsVUFBVSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7YUFDeEIsV0FBVyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUM7YUFDMUIsV0FBVyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztJQUNoQyxDQUFDOztBQW5CSCw4QkFvQkMifQ==
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
export * from './BaseClient';
|
|
18
|
+
export * from './ClientId';
|
|
19
|
+
export * from './Logger';
|
|
20
|
+
export * from './UserAgent';
|
|
21
|
+
export * from './RpcClient';
|
|
22
|
+
export * from './RpcClientManager';
|
|
23
|
+
export * from './SessionCredentials';
|
|
24
|
+
export * from './Settings';
|
|
25
|
+
export * from './TelemetrySession';
|
|
26
|
+
export * from './UserAgent';
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
21
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
23
|
+
}
|
|
24
|
+
Object.defineProperty(o, k2, desc);
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
30
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
__exportStar(require("./BaseClient"), exports);
|
|
34
|
+
__exportStar(require("./ClientId"), exports);
|
|
35
|
+
__exportStar(require("./Logger"), exports);
|
|
36
|
+
__exportStar(require("./UserAgent"), exports);
|
|
37
|
+
__exportStar(require("./RpcClient"), exports);
|
|
38
|
+
__exportStar(require("./RpcClientManager"), exports);
|
|
39
|
+
__exportStar(require("./SessionCredentials"), exports);
|
|
40
|
+
__exportStar(require("./Settings"), exports);
|
|
41
|
+
__exportStar(require("./TelemetrySession"), exports);
|
|
42
|
+
__exportStar(require("./UserAgent"), exports);
|
|
43
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpZW50L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFSCwrQ0FBNkI7QUFDN0IsNkNBQTJCO0FBQzNCLDJDQUF5QjtBQUN6Qiw4Q0FBNEI7QUFDNUIsOENBQTRCO0FBQzVCLHFEQUFtQztBQUNuQyx1REFBcUM7QUFDckMsNkNBQTJCO0FBQzNCLHFEQUFtQztBQUNuQyw4Q0FBNEIifQ==
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { ReceiveMessageRequest } from '../../proto/apache/rocketmq/v2/service_pb';
|
|
18
|
+
import { MessageView } from '../message';
|
|
19
|
+
import { MessageQueue } from '../route';
|
|
20
|
+
import { BaseClient, BaseClientOptions } from '../client';
|
|
21
|
+
import { FilterExpression } from './FilterExpression';
|
|
22
|
+
export interface ConsumerOptions extends BaseClientOptions {
|
|
23
|
+
consumerGroup: string;
|
|
24
|
+
}
|
|
25
|
+
export declare abstract class Consumer extends BaseClient {
|
|
26
|
+
protected readonly consumerGroup: string;
|
|
27
|
+
constructor(options: ConsumerOptions);
|
|
28
|
+
protected wrapReceiveMessageRequest(batchSize: number, mq: MessageQueue, filterExpression: FilterExpression, invisibleDuration: number, longPollingTimeout: number): ReceiveMessageRequest;
|
|
29
|
+
protected receiveMessage(request: ReceiveMessageRequest, mq: MessageQueue, awaitDuration: number): Promise<MessageView[]>;
|
|
30
|
+
protected ackMessage(messageView: MessageView): Promise<import("../../proto/apache/rocketmq/v2/service_pb").AckMessageResultEntry.AsObject[]>;
|
|
31
|
+
protected invisibleDuration(messageView: MessageView, invisibleDuration: number): Promise<string>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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.Consumer = void 0;
|
|
20
|
+
const service_pb_1 = require("../../proto/apache/rocketmq/v2/service_pb");
|
|
21
|
+
const message_1 = require("../message");
|
|
22
|
+
const exception_1 = require("../exception");
|
|
23
|
+
const client_1 = require("../client");
|
|
24
|
+
const util_1 = require("../util");
|
|
25
|
+
class Consumer extends client_1.BaseClient {
|
|
26
|
+
consumerGroup;
|
|
27
|
+
constructor(options) {
|
|
28
|
+
super(options);
|
|
29
|
+
this.consumerGroup = options.consumerGroup;
|
|
30
|
+
}
|
|
31
|
+
wrapReceiveMessageRequest(batchSize, mq, filterExpression, invisibleDuration, longPollingTimeout) {
|
|
32
|
+
return new service_pb_1.ReceiveMessageRequest()
|
|
33
|
+
.setGroup((0, util_1.createResource)(this.consumerGroup))
|
|
34
|
+
.setMessageQueue(mq.toProtobuf())
|
|
35
|
+
.setFilterExpression(filterExpression.toProtobuf())
|
|
36
|
+
.setLongPollingTimeout((0, util_1.createDuration)(longPollingTimeout))
|
|
37
|
+
.setBatchSize(batchSize)
|
|
38
|
+
.setAutoRenew(false)
|
|
39
|
+
.setInvisibleDuration((0, util_1.createDuration)(invisibleDuration));
|
|
40
|
+
}
|
|
41
|
+
async receiveMessage(request, mq, awaitDuration) {
|
|
42
|
+
const endpoints = mq.broker.endpoints;
|
|
43
|
+
const timeout = this.requestTimeout + awaitDuration;
|
|
44
|
+
let status;
|
|
45
|
+
const responses = await this.rpcClientManager.receiveMessage(endpoints, request, timeout);
|
|
46
|
+
const messageList = [];
|
|
47
|
+
let transportDeliveryTimestamp;
|
|
48
|
+
for (const response of responses) {
|
|
49
|
+
switch (response.getContentCase()) {
|
|
50
|
+
case service_pb_1.ReceiveMessageResponse.ContentCase.STATUS:
|
|
51
|
+
status = response.getStatus()?.toObject();
|
|
52
|
+
break;
|
|
53
|
+
case service_pb_1.ReceiveMessageResponse.ContentCase.MESSAGE:
|
|
54
|
+
messageList.push(response.getMessage());
|
|
55
|
+
break;
|
|
56
|
+
case service_pb_1.ReceiveMessageResponse.ContentCase.DELIVERY_TIMESTAMP:
|
|
57
|
+
transportDeliveryTimestamp = response.getDeliveryTimestamp()?.toDate();
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
// this.logger.warn("[Bug] Not recognized content for receive message response, mq={}, " +
|
|
61
|
+
// "clientId={}, response={}", mq, clientId, response);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exception_1.StatusChecker.check(status);
|
|
65
|
+
const messages = messageList.map(message => new message_1.MessageView(message, mq, transportDeliveryTimestamp));
|
|
66
|
+
return messages;
|
|
67
|
+
}
|
|
68
|
+
async ackMessage(messageView) {
|
|
69
|
+
const endpoints = messageView.endpoints;
|
|
70
|
+
const request = new service_pb_1.AckMessageRequest()
|
|
71
|
+
.setGroup((0, util_1.createResource)(this.consumerGroup))
|
|
72
|
+
.setTopic((0, util_1.createResource)(messageView.topic));
|
|
73
|
+
request.addEntries()
|
|
74
|
+
.setMessageId(messageView.messageId)
|
|
75
|
+
.setReceiptHandle(messageView.receiptHandle);
|
|
76
|
+
const res = await this.rpcClientManager.ackMessage(endpoints, request, this.requestTimeout);
|
|
77
|
+
// FIXME: handle fail ack
|
|
78
|
+
const response = res.toObject();
|
|
79
|
+
exception_1.StatusChecker.check(response.status);
|
|
80
|
+
return response.entriesList;
|
|
81
|
+
}
|
|
82
|
+
async invisibleDuration(messageView, invisibleDuration) {
|
|
83
|
+
const request = new service_pb_1.ChangeInvisibleDurationRequest()
|
|
84
|
+
.setGroup((0, util_1.createResource)(this.consumerGroup))
|
|
85
|
+
.setTopic((0, util_1.createResource)(messageView.topic))
|
|
86
|
+
.setReceiptHandle(messageView.receiptHandle)
|
|
87
|
+
.setInvisibleDuration((0, util_1.createDuration)(invisibleDuration))
|
|
88
|
+
.setMessageId(messageView.messageId);
|
|
89
|
+
const res = await this.rpcClientManager.changeInvisibleDuration(messageView.endpoints, request, this.requestTimeout);
|
|
90
|
+
const response = res.toObject();
|
|
91
|
+
exception_1.StatusChecker.check(response.status);
|
|
92
|
+
return response.receiptHandle;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.Consumer = Consumer;
|
|
96
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ29uc3VtZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uc3VtZXIvQ29uc3VtZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7O0FBR0gsMEVBSW1EO0FBQ25ELHdDQUF5QztBQUV6Qyw0Q0FBNkM7QUFDN0Msc0NBQTBEO0FBQzFELGtDQUF5RDtBQU96RCxNQUFzQixRQUFTLFNBQVEsbUJBQVU7SUFDNUIsYUFBYSxDQUFTO0lBRXpDLFlBQVksT0FBd0I7UUFDbEMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQ2YsSU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ZQUFZLENBQUMsV0FBVyxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBRXZDLE1BQU0sR0FBRyxHQUFHLE1BQU0sSUFBSSxDQUFDLGdCQUFnQixDQUFDLHVCQUF1QixDQUFDLFdBQVcsQ0FBQyxTQUFTLEVBQUUsT0FBTyxFQUFFLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQztRQUNySCxNQUFNLFFBQVEsR0FBRyxHQUFHLENBQUMsUUFBUSxFQUFFLENBQUM7UUFDaEMseUJBQWEsQ0FBQyxLQUFLLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxDQUFDO1FBQ3JDLE9BQU8sUUFBUSxDQUFDLGFBQWEsQ0FBQztJQUNoQyxDQUFDO0NBQ0Y7QUE1RUQsNEJBNEVDIn0=
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { FilterType, FilterExpression as FilterExpressionPB } from '../../proto/apache/rocketmq/v2/definition_pb';
|
|
18
|
+
export declare class FilterExpression {
|
|
19
|
+
static readonly SUB_ALL: FilterExpression;
|
|
20
|
+
readonly expression: string;
|
|
21
|
+
readonly filterType: FilterType;
|
|
22
|
+
constructor(expression: string, filterType?: FilterType);
|
|
23
|
+
toProtobuf(): FilterExpressionPB;
|
|
24
|
+
toString(): string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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.FilterExpression = void 0;
|
|
20
|
+
const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
|
|
21
|
+
const TAG_EXPRESSION_SUB_ALL = '*';
|
|
22
|
+
class FilterExpression {
|
|
23
|
+
static SUB_ALL = new FilterExpression(TAG_EXPRESSION_SUB_ALL);
|
|
24
|
+
expression;
|
|
25
|
+
filterType;
|
|
26
|
+
constructor(expression, filterType = definition_pb_1.FilterType.TAG) {
|
|
27
|
+
this.expression = expression;
|
|
28
|
+
this.filterType = filterType;
|
|
29
|
+
}
|
|
30
|
+
toProtobuf() {
|
|
31
|
+
return new definition_pb_1.FilterExpression()
|
|
32
|
+
.setType(this.filterType)
|
|
33
|
+
.setExpression(this.expression);
|
|
34
|
+
}
|
|
35
|
+
toString() {
|
|
36
|
+
return `FilterExpression(${this.filter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
|
|
4
|
-
|
|
5
|
-
|
|
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 { HeartbeatRequest, NotifyClientTerminationRequest } from '../../proto/apache/rocketmq/v2/service_pb';
|
|
18
|
+
import { MessageView } from '../message';
|
|
19
|
+
import { TopicRouteData } from '../route';
|
|
20
|
+
import { FilterExpression } from './FilterExpression';
|
|
21
|
+
import { SimpleSubscriptionSettings } from './SimpleSubscriptionSettings';
|
|
22
|
+
import { Consumer, ConsumerOptions } from './Consumer';
|
|
23
|
+
export interface SimpleConsumerOptions extends ConsumerOptions {
|
|
24
|
+
/**
|
|
25
|
+
* support tag string as filter, e.g.:
|
|
26
|
+
* ```ts
|
|
27
|
+
* new Map()
|
|
28
|
+
* .set('TestTopic1', 'TestTag1')
|
|
29
|
+
* .set('TestTopic2', 'TestTag2')
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
subscriptions: Map<string, FilterExpression | string>;
|
|
33
|
+
/**
|
|
34
|
+
* set await duration for long-polling, default is 30000ms
|
|
35
|
+
*/
|
|
36
|
+
awaitDuration?: number;
|
|
6
37
|
}
|
|
7
|
-
export declare class Consumer {
|
|
38
|
+
export declare class SimpleConsumer extends Consumer {
|
|
8
39
|
#private;
|
|
9
|
-
constructor(options:
|
|
10
|
-
|
|
40
|
+
constructor(options: SimpleConsumerOptions);
|
|
41
|
+
protected getSettings(): SimpleSubscriptionSettings;
|
|
42
|
+
protected wrapHeartbeatRequest(): HeartbeatRequest;
|
|
43
|
+
protected wrapNotifyClientTerminationRequest(): NotifyClientTerminationRequest;
|
|
44
|
+
protected onTopicRouteDataUpdate(topic: string, topicRouteData: TopicRouteData): void;
|
|
45
|
+
subscribe(topic: string, filterExpression: FilterExpression): Promise<void>;
|
|
46
|
+
unsubscribe(topic: string): void;
|
|
47
|
+
receive(maxMessageNum?: number, invisibleDuration?: number): Promise<MessageView[]>;
|
|
48
|
+
ack(message: MessageView): Promise<void>;
|
|
49
|
+
changeInvisibleDuration0(message: MessageView, invisibleDuration: number): Promise<void>;
|
|
11
50
|
}
|