rocketmq-client-nodejs-bate 1.0.12
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 +186 -0
- package/dist/client/BaseClient.d.ts +95 -0
- package/dist/client/BaseClient.js +324 -0
- package/dist/client/ClientId.d.ts +24 -0
- package/dist/client/ClientId.js +33 -0
- package/dist/client/Logger.d.ts +25 -0
- package/dist/client/Logger.js +33 -0
- package/dist/client/RpcClient.d.ts +48 -0
- package/dist/client/RpcClient.js +219 -0
- package/dist/client/RpcClientManager.d.ts +42 -0
- package/dist/client/RpcClientManager.js +144 -0
- package/dist/client/SessionCredentials.d.ts +21 -0
- package/dist/client/SessionCredentials.js +19 -0
- package/dist/client/Settings.d.ts +31 -0
- package/dist/client/Settings.js +40 -0
- package/dist/client/TelemetrySession.d.ts +27 -0
- package/dist/client/TelemetrySession.js +110 -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/Assignment.d.ts +23 -0
- package/dist/consumer/Assignment.js +40 -0
- package/dist/consumer/Assignments.d.ts +24 -0
- package/dist/consumer/Assignments.js +47 -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 +49 -0
- package/dist/consumer/ConsumeTask.d.ts +24 -0
- package/dist/consumer/ConsumeTask.js +40 -0
- package/dist/consumer/Consumer.d.ts +38 -0
- package/dist/consumer/Consumer.js +111 -0
- package/dist/consumer/FifoConsumeService.d.ts +25 -0
- package/dist/consumer/FifoConsumeService.js +123 -0
- package/dist/consumer/FilterExpression.d.ts +25 -0
- package/dist/consumer/FilterExpression.js +40 -0
- package/dist/consumer/MessageListener.d.ts +21 -0
- package/dist/consumer/MessageListener.js +19 -0
- package/dist/consumer/ProcessQueue.d.ts +39 -0
- package/dist/consumer/ProcessQueue.js +286 -0
- package/dist/consumer/PushConsumer.d.ts +68 -0
- package/dist/consumer/PushConsumer.js +377 -0
- package/dist/consumer/PushSubscriptionSettings.d.ts +31 -0
- package/dist/consumer/PushSubscriptionSettings.js +97 -0
- package/dist/consumer/SimpleConsumer.d.ts +50 -0
- package/dist/consumer/SimpleConsumer.js +122 -0
- package/dist/consumer/SimpleSubscriptionSettings.d.ts +28 -0
- package/dist/consumer/SimpleSubscriptionSettings.js +57 -0
- package/dist/consumer/StandardConsumeService.d.ts +24 -0
- package/dist/consumer/StandardConsumeService.js +42 -0
- package/dist/consumer/SubscriptionLoadBalancer.d.ts +23 -0
- package/dist/consumer/SubscriptionLoadBalancer.js +46 -0
- package/dist/consumer/index.d.ts +32 -0
- package/dist/consumer/index.js +49 -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 -0
- package/dist/index.js +39 -0
- package/dist/message/Message.d.ts +38 -0
- package/dist/message/Message.js +57 -0
- package/dist/message/MessageId.d.ts +59 -0
- package/dist/message/MessageId.js +123 -0
- package/dist/message/MessageView.d.ts +38 -0
- package/dist/message/MessageView.js +90 -0
- package/dist/message/PublishingMessage.d.ts +30 -0
- package/dist/message/PublishingMessage.js +100 -0
- package/dist/message/index.d.ts +20 -0
- package/dist/message/index.js +37 -0
- package/dist/producer/Producer.d.ts +55 -0
- package/dist/producer/Producer.js +318 -0
- 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/RecallReceipt.d.ts +25 -0
- package/dist/producer/RecallReceipt.js +34 -0
- package/dist/producer/SendReceipt.d.ts +29 -0
- package/dist/producer/SendReceipt.js +60 -0
- package/dist/producer/Transaction.d.ts +28 -0
- package/dist/producer/Transaction.js +70 -0
- package/dist/producer/TransactionChecker.d.ts +21 -0
- package/dist/producer/TransactionChecker.js +19 -0
- package/dist/producer/index.d.ts +22 -0
- package/dist/producer/index.js +40 -0
- package/dist/retry/ExponentialBackoffRetryPolicy.d.ts +27 -0
- package/dist/retry/ExponentialBackoffRetryPolicy.js +64 -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 +35 -0
- package/dist/util/index.js +88 -0
- package/package.json +62 -0
- package/proto/apache/rocketmq/v2/admin.proto +43 -0
- package/proto/apache/rocketmq/v2/admin_grpc_pb.d.ts +41 -0
- package/proto/apache/rocketmq/v2/admin_grpc_pb.js +60 -0
- package/proto/apache/rocketmq/v2/admin_pb.d.ts +56 -0
- package/proto/apache/rocketmq/v2/admin_pb.js +340 -0
- package/proto/apache/rocketmq/v2/definition.proto +570 -0
- package/proto/apache/rocketmq/v2/definition_grpc_pb.js +1 -0
- package/proto/apache/rocketmq/v2/definition_pb.d.ts +885 -0
- package/proto/apache/rocketmq/v2/definition_pb.js +6141 -0
- package/proto/apache/rocketmq/v2/service.proto +443 -0
- package/proto/apache/rocketmq/v2/service_grpc_pb.d.ts +294 -0
- package/proto/apache/rocketmq/v2/service_grpc_pb.js +637 -0
- package/proto/apache/rocketmq/v2/service_pb.d.ts +1249 -0
- package/proto/apache/rocketmq/v2/service_pb.js +9723 -0
- package/src/client/BaseClient.ts +404 -0
- package/src/client/ClientId.ts +31 -0
- package/src/client/Logger.ts +36 -0
- package/src/client/RpcClient.ts +258 -0
- package/src/client/RpcClientManager.ts +180 -0
- package/src/client/SessionCredentials.ts +22 -0
- package/src/client/Settings.ts +46 -0
- package/src/client/TelemetrySession.ts +130 -0
- package/src/client/UserAgent.ts +45 -0
- package/src/client/index.ts +27 -0
- package/src/consumer/Assignment.ts +39 -0
- package/src/consumer/Assignments.ts +46 -0
- package/src/consumer/ConsumeResult.ts +21 -0
- package/src/consumer/ConsumeService.ts +54 -0
- package/src/consumer/ConsumeTask.ts +40 -0
- package/src/consumer/Consumer.ts +129 -0
- package/src/consumer/FifoConsumeService.ts +136 -0
- package/src/consumer/FilterExpression.ts +42 -0
- package/src/consumer/MessageListener.ts +23 -0
- package/src/consumer/ProcessQueue.ts +326 -0
- package/src/consumer/PushConsumer.ts +473 -0
- package/src/consumer/PushSubscriptionSettings.ts +123 -0
- package/src/consumer/SimpleConsumer.ts +153 -0
- package/src/consumer/SimpleSubscriptionSettings.ts +64 -0
- package/src/consumer/StandardConsumeService.ts +44 -0
- package/src/consumer/SubscriptionLoadBalancer.ts +47 -0
- package/src/consumer/index.ts +33 -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 -0
- package/src/message/Message.ts +67 -0
- package/src/message/MessageId.ts +123 -0
- package/src/message/MessageView.ts +94 -0
- package/src/message/PublishingMessage.ts +104 -0
- package/src/message/index.ts +21 -0
- package/src/producer/Producer.ts +388 -0
- package/src/producer/PublishingLoadBalancer.ts +85 -0
- package/src/producer/PublishingSettings.ts +78 -0
- package/src/producer/RecallReceipt.ts +32 -0
- package/src/producer/SendReceipt.ts +63 -0
- package/src/producer/Transaction.ts +86 -0
- package/src/producer/TransactionChecker.ts +23 -0
- package/src/producer/index.ts +24 -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
|
@@ -0,0 +1,46 @@
|
|
|
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("./BadRequestException"), exports);
|
|
34
|
+
__exportStar(require("./ClientException"), exports);
|
|
35
|
+
__exportStar(require("./ForbiddenException"), exports);
|
|
36
|
+
__exportStar(require("./InternalErrorException"), exports);
|
|
37
|
+
__exportStar(require("./NotFoundException"), exports);
|
|
38
|
+
__exportStar(require("./PayloadTooLargeException"), exports);
|
|
39
|
+
__exportStar(require("./PaymentRequiredException"), exports);
|
|
40
|
+
__exportStar(require("./ProxyTimeoutException"), exports);
|
|
41
|
+
__exportStar(require("./RequestHeaderFieldsTooLargeException"), exports);
|
|
42
|
+
__exportStar(require("./StatusChecker"), exports);
|
|
43
|
+
__exportStar(require("./TooManyRequestsException"), exports);
|
|
44
|
+
__exportStar(require("./UnauthorizedException"), exports);
|
|
45
|
+
__exportStar(require("./UnsupportedException"), exports);
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZXhjZXB0aW9uL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFSCx3REFBc0M7QUFDdEMsb0RBQWtDO0FBQ2xDLHVEQUFxQztBQUNyQywyREFBeUM7QUFDekMsc0RBQW9DO0FBQ3BDLDZEQUEyQztBQUMzQyw2REFBMkM7QUFDM0MsMERBQXdDO0FBQ3hDLHlFQUF1RDtBQUN2RCxrREFBZ0M7QUFDaEMsNkRBQTJDO0FBQzNDLDBEQUF3QztBQUN4Qyx5REFBdUMifQ==
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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 './consumer';
|
|
18
|
+
export * from './exception';
|
|
19
|
+
export * from './message';
|
|
20
|
+
export * from './producer';
|
|
21
|
+
export * from './retry';
|
|
22
|
+
export * from './route';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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("./consumer"), exports);
|
|
34
|
+
__exportStar(require("./exception"), exports);
|
|
35
|
+
__exportStar(require("./message"), exports);
|
|
36
|
+
__exportStar(require("./producer"), exports);
|
|
37
|
+
__exportStar(require("./retry"), exports);
|
|
38
|
+
__exportStar(require("./route"), exports);
|
|
39
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7Ozs7Ozs7Ozs7Ozs7OztBQUVILDZDQUEyQjtBQUMzQiw4Q0FBNEI7QUFDNUIsNENBQTBCO0FBQzFCLDZDQUEyQjtBQUMzQiwwQ0FBd0I7QUFDeEIsMENBQXdCIn0=
|
|
@@ -0,0 +1,38 @@
|
|
|
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 interface MessageOptions {
|
|
18
|
+
topic: string;
|
|
19
|
+
body: Buffer;
|
|
20
|
+
tag?: string;
|
|
21
|
+
messageGroup?: string;
|
|
22
|
+
keys?: string[];
|
|
23
|
+
properties?: Map<string, string>;
|
|
24
|
+
delay?: number;
|
|
25
|
+
deliveryTimestamp?: Date;
|
|
26
|
+
priority?: number;
|
|
27
|
+
}
|
|
28
|
+
export declare class Message {
|
|
29
|
+
topic: string;
|
|
30
|
+
body: Buffer;
|
|
31
|
+
tag?: string;
|
|
32
|
+
messageGroup?: string;
|
|
33
|
+
keys: string[];
|
|
34
|
+
properties?: Map<string, string>;
|
|
35
|
+
deliveryTimestamp?: Date;
|
|
36
|
+
priority?: number;
|
|
37
|
+
constructor(options: MessageOptions);
|
|
38
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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.Message = void 0;
|
|
20
|
+
class Message {
|
|
21
|
+
topic;
|
|
22
|
+
body;
|
|
23
|
+
tag;
|
|
24
|
+
messageGroup;
|
|
25
|
+
keys;
|
|
26
|
+
properties;
|
|
27
|
+
deliveryTimestamp;
|
|
28
|
+
priority;
|
|
29
|
+
constructor(options) {
|
|
30
|
+
// Validate priority and mutual exclusivity
|
|
31
|
+
if (options.priority !== undefined) {
|
|
32
|
+
if (options.priority < 0) {
|
|
33
|
+
throw new Error('priority must be greater than or equal to 0');
|
|
34
|
+
}
|
|
35
|
+
if (options.deliveryTimestamp) {
|
|
36
|
+
throw new Error('priority and deliveryTimestamp should not be set at same time');
|
|
37
|
+
}
|
|
38
|
+
if (options.messageGroup) {
|
|
39
|
+
throw new Error('priority and messageGroup should not be set at same time');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
this.topic = options.topic;
|
|
43
|
+
this.body = options.body;
|
|
44
|
+
this.tag = options.tag;
|
|
45
|
+
this.messageGroup = options.messageGroup;
|
|
46
|
+
this.keys = options.keys ?? [];
|
|
47
|
+
this.properties = options.properties;
|
|
48
|
+
let deliveryTimestamp = options.deliveryTimestamp;
|
|
49
|
+
if (options.delay && !deliveryTimestamp) {
|
|
50
|
+
deliveryTimestamp = new Date(Date.now() + options.delay);
|
|
51
|
+
}
|
|
52
|
+
this.deliveryTimestamp = deliveryTimestamp;
|
|
53
|
+
this.priority = options.priority;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.Message = Message;
|
|
57
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWVzc2FnZS5qcyIsInNv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LFlBQVksQ0FBQztRQUN6QyxJQUFJLENBQUMsSUFBSSxHQUFHLE9BQU8sQ0FBQyxJQUFJLElBQUksRUFBRSxDQUFDO1FBQy9CLElBQUksQ0FBQyxVQUFVLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQztRQUNyQyxJQUFJLGlCQUFpQixHQUFHLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQztRQUNsRCxJQUFJLE9BQU8sQ0FBQyxLQUFLLElBQUksQ0FBQyxpQkFBaUIsRUFBRSxDQUFDO1lBQ3hDLGlCQUFpQixHQUFHLElBQUksSUFBSSxDQUFDLElBQUksQ0FBQyxHQUFHLEVBQUUsR0FBRyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDM0QsQ0FBQztRQUNELElBQUksQ0FBQyxpQkFBaUIsR0FBRyxpQkFBaUIsQ0FBQztRQUMzQyxJQUFJLENBQUMsUUFBUSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUM7SUFDbkMsQ0FBQztDQUNGO0FBckNELDBCQXFDQyJ9
|
|
@@ -0,0 +1,59 @@
|
|
|
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 declare enum MESSAGE_VERSION {
|
|
18
|
+
V0 = 0,
|
|
19
|
+
V1 = 1
|
|
20
|
+
}
|
|
21
|
+
export declare class MessageId {
|
|
22
|
+
id: string;
|
|
23
|
+
/**
|
|
24
|
+
* e.g.: 0x01: fixed 1 byte for current version
|
|
25
|
+
* offset = 0
|
|
26
|
+
*/
|
|
27
|
+
version: MESSAGE_VERSION;
|
|
28
|
+
/**
|
|
29
|
+
* e.g.: 0x56F7E71C361B: lower 6 bytes of local mac address
|
|
30
|
+
* offset = 1
|
|
31
|
+
*/
|
|
32
|
+
macAddress: string;
|
|
33
|
+
/**
|
|
34
|
+
* e.g.: 0x21BC: lower 2 bytes of process id
|
|
35
|
+
* offset = 7
|
|
36
|
+
*/
|
|
37
|
+
processId: number;
|
|
38
|
+
/**
|
|
39
|
+
* e.g: 0x024CCDBE: seconds since 2021-01-01 00:00:00(UTC+0, lower 4 bytes)
|
|
40
|
+
* offset = 9
|
|
41
|
+
*/
|
|
42
|
+
timestamp: number;
|
|
43
|
+
/**
|
|
44
|
+
* e.g.: 0x00000000: sequence number(4 bytes)
|
|
45
|
+
* offset = 13
|
|
46
|
+
*/
|
|
47
|
+
sequence: number;
|
|
48
|
+
toString(): string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Message Identifier
|
|
52
|
+
* https://github.com/apache/rocketmq-clients/blob/master/docs/message_id.md
|
|
53
|
+
*/
|
|
54
|
+
export declare class MessageIdFactory {
|
|
55
|
+
#private;
|
|
56
|
+
static MAC: string;
|
|
57
|
+
static create(): MessageId;
|
|
58
|
+
static decode(id: string): MessageId;
|
|
59
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
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.MessageIdFactory = exports.MessageId = exports.MESSAGE_VERSION = void 0;
|
|
23
|
+
const address_1 = __importDefault(require("address"));
|
|
24
|
+
var MESSAGE_VERSION;
|
|
25
|
+
(function (MESSAGE_VERSION) {
|
|
26
|
+
MESSAGE_VERSION[MESSAGE_VERSION["V0"] = 0] = "V0";
|
|
27
|
+
MESSAGE_VERSION[MESSAGE_VERSION["V1"] = 1] = "V1";
|
|
28
|
+
})(MESSAGE_VERSION || (exports.MESSAGE_VERSION = MESSAGE_VERSION = {}));
|
|
29
|
+
class MessageId {
|
|
30
|
+
id;
|
|
31
|
+
/**
|
|
32
|
+
* e.g.: 0x01: fixed 1 byte for current version
|
|
33
|
+
* offset = 0
|
|
34
|
+
*/
|
|
35
|
+
version;
|
|
36
|
+
/**
|
|
37
|
+
* e.g.: 0x56F7E71C361B: lower 6 bytes of local mac address
|
|
38
|
+
* offset = 1
|
|
39
|
+
*/
|
|
40
|
+
macAddress;
|
|
41
|
+
/**
|
|
42
|
+
* e.g.: 0x21BC: lower 2 bytes of process id
|
|
43
|
+
* offset = 7
|
|
44
|
+
*/
|
|
45
|
+
processId;
|
|
46
|
+
/**
|
|
47
|
+
* e.g: 0x024CCDBE: seconds since 2021-01-01 00:00:00(UTC+0, lower 4 bytes)
|
|
48
|
+
* offset = 9
|
|
49
|
+
*/
|
|
50
|
+
timestamp;
|
|
51
|
+
/**
|
|
52
|
+
* e.g.: 0x00000000: sequence number(4 bytes)
|
|
53
|
+
* offset = 13
|
|
54
|
+
*/
|
|
55
|
+
sequence;
|
|
56
|
+
toString() {
|
|
57
|
+
return this.id;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.MessageId = MessageId;
|
|
61
|
+
const MAX_UINT32 = 0xFFFFFFFF;
|
|
62
|
+
const MAX_UINT16 = 0xFFFF;
|
|
63
|
+
/**
|
|
64
|
+
* Message Identifier
|
|
65
|
+
* https://github.com/apache/rocketmq-clients/blob/master/docs/message_id.md
|
|
66
|
+
*/
|
|
67
|
+
class MessageIdFactory {
|
|
68
|
+
// static #hostname = hostname();
|
|
69
|
+
static #sequence = 0;
|
|
70
|
+
static #buf = Buffer.alloc(1 + 6 + 2 + 4 + 4);
|
|
71
|
+
// 2021-01-01 00:00:00(UTC+0), 1609459200000
|
|
72
|
+
static #sinceTimestamp = new Date('2021-01-01T00:00:00Z').getTime() / 1000;
|
|
73
|
+
// lower 2 bytes of process id
|
|
74
|
+
static #processId = process.pid % MAX_UINT16;
|
|
75
|
+
static MAC = '000000000000';
|
|
76
|
+
static create() {
|
|
77
|
+
const messageId = new MessageId();
|
|
78
|
+
messageId.version = MESSAGE_VERSION.V1;
|
|
79
|
+
messageId.macAddress = this.MAC;
|
|
80
|
+
messageId.processId = this.#processId;
|
|
81
|
+
messageId.timestamp = this.#getCurrentTimestamp();
|
|
82
|
+
messageId.sequence = this.#sequence++;
|
|
83
|
+
if (this.#sequence > MAX_UINT32) {
|
|
84
|
+
this.#sequence = 0;
|
|
85
|
+
}
|
|
86
|
+
this.#buf.writeUInt8(messageId.version, 0);
|
|
87
|
+
this.#buf.write(messageId.macAddress, 1, 'hex');
|
|
88
|
+
this.#buf.writeUInt16BE(messageId.processId, 7);
|
|
89
|
+
this.#buf.writeUInt32BE(messageId.timestamp, 9);
|
|
90
|
+
this.#buf.writeUInt32BE(messageId.sequence, 13);
|
|
91
|
+
messageId.id = this.#buf.toString('hex').toUpperCase();
|
|
92
|
+
return messageId;
|
|
93
|
+
}
|
|
94
|
+
static decode(id) {
|
|
95
|
+
const messageId = new MessageId();
|
|
96
|
+
messageId.id = id;
|
|
97
|
+
this.#buf.write(id, 0, 'hex');
|
|
98
|
+
messageId.version = this.#buf.readUInt8(0);
|
|
99
|
+
messageId.macAddress = this.#buf.subarray(1, 7).toString('hex');
|
|
100
|
+
messageId.processId = this.#buf.readUInt16BE(7);
|
|
101
|
+
messageId.timestamp = this.#buf.readUInt32BE(9);
|
|
102
|
+
messageId.sequence = this.#buf.readUInt32BE(13);
|
|
103
|
+
return messageId;
|
|
104
|
+
}
|
|
105
|
+
static #getCurrentTimestamp() {
|
|
106
|
+
// use lower 4 bytes
|
|
107
|
+
return Math.floor(Date.now() / 1000 - this.#sinceTimestamp) % MAX_UINT32;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.MessageIdFactory = MessageIdFactory;
|
|
111
|
+
// set current mac address
|
|
112
|
+
address_1.default.mac((err, mac) => {
|
|
113
|
+
if (err) {
|
|
114
|
+
console.warn('[rocketmq-client-nodejs] can\'t get mac address, %s', err.message);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (!mac) {
|
|
118
|
+
console.warn('[rocketmq-client-nodejs] can\'t get mac address');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
MessageIdFactory.MAC = mac.replaceAll(':', '');
|
|
122
|
+
});
|
|
123
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWVzc2FnZUlkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL21lc3NhZ2UvTWVzc2FnZUlkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ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W9CO1FBQ3BCLE9BQU8sSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsR0FBRyxFQUFFLEdBQUcsSUFBSSxHQUFHLElBQUksQ0FBQyxlQUFlLENBQUMsR0FBRyxVQUFVLENBQUM7SUFDM0UsQ0FBQzs7QUE1Q0gsNENBNkNDO0FBRUQsMEJBQTBCO0FBQzFCLGlCQUFPLENBQUMsR0FBRyxDQUFDLENBQUMsR0FBRyxFQUFFLEdBQUcsRUFBRSxFQUFFO0lBQ3ZCLElBQUksR0FBRyxFQUFFLENBQUM7UUFDUixPQUFPLENBQUMsSUFBSSxDQUFDLHFEQUFxRCxFQUFFLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQztRQUNqRixPQUFPO0lBQ1QsQ0FBQztJQUNELElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQztRQUNULE9BQU8sQ0FBQyxJQUFJLENBQUMsaURBQWlELENBQUMsQ0FBQztRQUNoRSxPQUFPO0lBQ1QsQ0FBQztJQUNELGdCQUFnQixDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUMsVUFBVSxDQUFDLEdBQUcsRUFBRSxFQUFFLENBQUMsQ0FBQztBQUNqRCxDQUFDLENBQUMsQ0FBQyJ9
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { Message as MessagePB } from '../../proto/apache/rocketmq/v2/definition_pb';
|
|
18
|
+
import { Endpoints, MessageQueue } from '../route';
|
|
19
|
+
export declare class MessageView {
|
|
20
|
+
readonly messageId: string;
|
|
21
|
+
readonly topic: string;
|
|
22
|
+
readonly body: Buffer;
|
|
23
|
+
readonly corrupted: boolean;
|
|
24
|
+
readonly transportDeliveryTimestamp?: Date;
|
|
25
|
+
readonly tag?: string;
|
|
26
|
+
readonly messageGroup?: string;
|
|
27
|
+
readonly deliveryTimestamp?: Date;
|
|
28
|
+
readonly keys: string[];
|
|
29
|
+
readonly bornHost: string;
|
|
30
|
+
readonly bornTimestamp?: Date;
|
|
31
|
+
readonly deliveryAttempt?: number;
|
|
32
|
+
readonly endpoints: Endpoints;
|
|
33
|
+
readonly receiptHandle: string;
|
|
34
|
+
readonly offset?: number;
|
|
35
|
+
readonly decodeTimestamp: Date;
|
|
36
|
+
readonly properties: Map<string, string>;
|
|
37
|
+
constructor(message: MessagePB, messageQueue?: MessageQueue, transportDeliveryTimestamp?: Date);
|
|
38
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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.MessageView = void 0;
|
|
20
|
+
const node_zlib_1 = require("node:zlib");
|
|
21
|
+
const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
|
|
22
|
+
const util_1 = require("../util");
|
|
23
|
+
class MessageView {
|
|
24
|
+
messageId;
|
|
25
|
+
topic;
|
|
26
|
+
body;
|
|
27
|
+
corrupted;
|
|
28
|
+
transportDeliveryTimestamp;
|
|
29
|
+
tag;
|
|
30
|
+
messageGroup;
|
|
31
|
+
deliveryTimestamp;
|
|
32
|
+
keys;
|
|
33
|
+
bornHost;
|
|
34
|
+
bornTimestamp;
|
|
35
|
+
deliveryAttempt;
|
|
36
|
+
endpoints;
|
|
37
|
+
receiptHandle;
|
|
38
|
+
offset;
|
|
39
|
+
decodeTimestamp;
|
|
40
|
+
properties = new Map();
|
|
41
|
+
constructor(message, messageQueue, transportDeliveryTimestamp) {
|
|
42
|
+
const systemProperties = message.getSystemProperties();
|
|
43
|
+
const bodyDigest = systemProperties.getBodyDigest().toObject();
|
|
44
|
+
const digestType = bodyDigest.type;
|
|
45
|
+
const checksum = bodyDigest.checksum;
|
|
46
|
+
let expectedChecksum = '';
|
|
47
|
+
let bodyBytes = Buffer.from(message.getBody_asU8());
|
|
48
|
+
switch (digestType) {
|
|
49
|
+
case definition_pb_1.DigestType.CRC32:
|
|
50
|
+
expectedChecksum = (0, util_1.crc32CheckSum)(bodyBytes);
|
|
51
|
+
break;
|
|
52
|
+
case definition_pb_1.DigestType.MD5:
|
|
53
|
+
expectedChecksum = (0, util_1.md5CheckSum)(bodyBytes);
|
|
54
|
+
break;
|
|
55
|
+
case definition_pb_1.DigestType.SHA1:
|
|
56
|
+
expectedChecksum = (0, util_1.sha1CheckSum)(bodyBytes);
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
// log.error("Unsupported message body digest algorithm, digestType={}, topic={}, messageId={}",
|
|
60
|
+
// digestType, topic, messageId);
|
|
61
|
+
}
|
|
62
|
+
if (expectedChecksum && expectedChecksum !== checksum) {
|
|
63
|
+
this.corrupted = true;
|
|
64
|
+
}
|
|
65
|
+
if (systemProperties.getBodyEncoding() === definition_pb_1.Encoding.GZIP) {
|
|
66
|
+
bodyBytes = (0, node_zlib_1.gunzipSync)(bodyBytes);
|
|
67
|
+
}
|
|
68
|
+
for (const [key, value] of message.getUserPropertiesMap().entries()) {
|
|
69
|
+
this.properties.set(key, value);
|
|
70
|
+
}
|
|
71
|
+
this.messageId = systemProperties.getMessageId();
|
|
72
|
+
this.topic = message.getTopic().getName();
|
|
73
|
+
this.tag = systemProperties.getTag();
|
|
74
|
+
this.messageGroup = systemProperties.getMessageGroup();
|
|
75
|
+
this.deliveryTimestamp = systemProperties.getDeliveryTimestamp()?.toDate();
|
|
76
|
+
this.keys = systemProperties.getKeysList();
|
|
77
|
+
this.bornHost = systemProperties.getBornHost();
|
|
78
|
+
this.bornTimestamp = systemProperties.getBornTimestamp()?.toDate();
|
|
79
|
+
this.deliveryAttempt = systemProperties.getDeliveryAttempt();
|
|
80
|
+
this.offset = systemProperties.getQueueOffset();
|
|
81
|
+
this.receiptHandle = systemProperties.getReceiptHandle();
|
|
82
|
+
this.transportDeliveryTimestamp = transportDeliveryTimestamp;
|
|
83
|
+
if (messageQueue) {
|
|
84
|
+
this.endpoints = messageQueue.broker.endpoints;
|
|
85
|
+
}
|
|
86
|
+
this.body = bodyBytes;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.MessageView = MessageView;
|
|
90
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWVzc2FnZVZpZXcuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbWVzc2FnZS9NZXNz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ensed 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 { MessageType, Message as MessagePB } from '../../proto/apache/rocketmq/v2/definition_pb';
|
|
18
|
+
import { PublishingSettings } from '../producer';
|
|
19
|
+
import { MessageQueue } from '../route';
|
|
20
|
+
import { Message, MessageOptions } from './Message';
|
|
21
|
+
export declare class PublishingMessage extends Message {
|
|
22
|
+
readonly messageId: string;
|
|
23
|
+
readonly messageType: MessageType;
|
|
24
|
+
constructor(options: MessageOptions, publishingSettings: PublishingSettings, txEnabled: boolean);
|
|
25
|
+
/**
|
|
26
|
+
* This method should be invoked before each message sending, because the born time is reset before each
|
|
27
|
+
* invocation, which means that it should not be invoked ahead of time.
|
|
28
|
+
*/
|
|
29
|
+
toProtobuf(namespace: string, mq: MessageQueue): MessagePB;
|
|
30
|
+
}
|