1 Star 1 Fork 54

八步赶蝉 / folkmq

forked from noear / folkmq 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
API.md 2.19 KB
一键复制 编辑 原始数据 按行查看 历史
西东 提交于 2023-12-02 08:51 . Update API.md

MqClient 接口

/**
 * 消息客户端
 *
 * @author noear
 * @since 1.0
 */
public interface MqClient {
    /**
     * 连接
     */
    MqClient connect() throws IOException;

    /**
     * 断开连接
     */
    void disconnect() throws IOException;

    /**
     * 客户端配置
     */
    MqClient config(ClientConfigHandler configHandler);

    /**
     * 自动回执
     *
     * @param auto 自动(默认为 true)
     */
    MqClient autoAcknowledge(boolean auto);

    /**
     * 发布重试
     *
     * @param times 次数(默认为 0)
     * */
    MqClient publishRetryTimes(int times);

    /**
     * 订阅主题
     *
     * @param topic           主题
     * @param consumer        消费者(实例 ip 或 集群 name)
     * @param consumerHandler 消费处理
     */
    void subscribe(String topic, String consumer, MqConsumeHandler consumerHandler) throws IOException;

    /**
     * 取消订阅主题
     *
     * @param topic    主题
     * @param consumer 消费者(实例 ip 或 集群 name)
     */
    void unsubscribe(String topic, String consumer) throws IOException;

    /**
     * 发布消息
     *
     * @param topic     主题
     * @param message   消息
     */
    CompletableFuture<?> publish(String topic, IMqMessage message) throws IOException;
}

IMqMessage 接口

/**
 * 消息接口
 */
public interface IMqMessage {
    /**
     * 事务ID
     */
    String getTid();

    /**
     * 内容
     */
    String getContent();

    /**
     * 定时时间
     */
    Date getScheduled();

    /**
     * 质量等级(0 或 1)
     */
    int getQos();
}

MqConsumeHandler 接口

/**
 * 消费处理器
 */
public interface MqConsumeHandler {
    /**
     * 消费
     * 
     * @param message 收到的消息
     */
    void consume(MqMessage message) throws IOException;
}

MqMessage 接口

/**
 * 收到的消息接口
 */
public interface IMqMessageReceived extends IMqMessage {
    /**
     * 主题
     */
    String getTopic();

    /**
     * 已派发次数
     */
    int getTimes();

    /**
     * 回执
     */
    void acknowledge(boolean isOk) throws IOException;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/giteeliuyan/folkmq.git
git@gitee.com:giteeliuyan/folkmq.git
giteeliuyan
folkmq
folkmq
main

搜索帮助

344bd9b3 5694891 D2dac590 5694891