UNPKG

@klsakura/rocketmq-native-sdk

Version:

High-performance Node.js client SDK for RocketMQ with Native Addon support (Node.js 16+)

87 lines 2.87 kB
export interface MQConfig { endpoint: string; accessKeyId: string; accessKeySecret: string; instanceId: string; logLevel?: string; thread?: number; } export interface MessageData { messageId: string; receiptHandle: string; body: string; tag: string; properties: { [key: string]: string; }; bornTimestamp: number; reconsumeTimes: number; } export interface SendResult { messageId: string; receiptHandle: string; } export interface DelayOptions { delayTimeLevel?: number; startDeliverTime?: number; } export declare class MessageProperties { properties: { [key: string]: string; }; message_key: string; sharding_key: string; start_deliver_time: number; trans_check_immunity_time: number; putProperty(key: string, value: string | number): MessageProperties; messageKey(key: string): MessageProperties; shardingKey(key: string): MessageProperties; startDeliverTime(time: number): MessageProperties; transCheckImmunityTime(time: number): MessageProperties; toJSON(): any; } export declare abstract class Producer { abstract publishMessage(messageBody: any, tag?: string, properties?: MessageProperties | null): Promise<SendResult>; abstract publishOrderedMessage(messageBody: any, tag?: string, properties?: MessageProperties | null, shardingKey?: string): Promise<SendResult>; abstract publishDelayMessage(messageBody: any, tag?: string, properties?: MessageProperties | null, options?: DelayOptions): Promise<SendResult>; abstract shutdown(): Promise<any>; } export declare abstract class Consumer { protected messageHandlers: Array<(message: MessageData) => void | Promise<void>>; abstract onMessage(handler: (message: MessageData) => void | Promise<void>): void; abstract startReceiving(tagExpression?: string): any; abstract ackMessage(receiptHandle: string): Promise<any>; abstract shutdown(): Promise<any>; } export declare class MQClient { private client; private initialized; constructor(config: MQConfig); private ensureInitialized; /** * 创建生产者 * @param instanceId 实例ID * @param topic 主题 * @returns 生产者实例 */ getProducer(instanceId: string, topic: string): Promise<Producer>; /** * 创建消费者 * @param instanceId 实例ID * @param topic 主题 * @param groupId 消费者组ID * @param tagExpression 标签表达式 (默认为'*') * @returns 消费者实例 */ getConsumer(instanceId: string, topic: string, groupId: string, tagExpression?: string): Promise<Consumer>; /** * 健康检查 */ healthCheck(): Promise<any>; /** * 获取客户端模式 */ getMode(): string; } export default MQClient; //# sourceMappingURL=index.d.ts.map