FolkMQ v1.7.8

客户端接口字典

消息客户端接口参考

export interface MqClient {
    //名字
    name(): string;

    //配置名字(即默认的消费者组)
    nameAs(name: string): MqClient;

    //连接
    connect(): Promise<MqClient>;

    //断开连接
    disconnect();

    //客户端配置
    config(configHandler: IoConsumer<ClientConfig>): MqClient;

    //配置自动回执
    autoAcknowledge(auto: boolean): MqClient;

    /**
     * 订阅主题
     *
     * @param topic           主题
     * @param consumerGroup   消费者组
     * @param consumerHandler 消费处理
     */
    subscribe(topic: string, consumerGroup: string | null, autoAck: boolean | null, consumerHandler: IoConsumer<MqMessageReceived>);

    /**
     * 取消订阅主题
     *
     * @param topic         主题
     * @param consumerGroup 消费者组
     */
    unsubscribe(topic: string, consumerGroup: string | null);

    /**
     * 同步发布消息
     *
     * @param topic   主题
     * @param message 消息
     */
    publish(topic: string, message: MqMessage);

    /**
     * 取消发布
     *
     * @param topic 主题
     * @param tid   跟踪id
     */
    unpublish(topic: string, tid: string);

    //配置事务回查接口
    transactionCheckback(transactionCheckback: IoConsumer<MqMessageReceived>);

    //新建事务
    newTransaction(): MqTransaction;
}