MqController MQ消息队列 代码下载

1.用户注册

接口名 用户注册
调用地址 /api/MqController/register
参数 actype int 接口类型
sbscrbtp string 订阅类型
route string 路由(value可为空)
utype string 订阅者/消费者
调用示例 http://localhost:port/api/MqController/register?actype=10
返回值说明 code:code码(100:成功;101:失败)
msg:消息
user:用户信息
返回值示例 {
    "code": 100,
    "msg": "用户注册成功",
    "user": "User{id=4, utype=1, creattime='2025-03-06 11:55:28',
sbscrbtp=1, route='123123', token='b67e7afa293043129c7d'}"
}

2.消息发布

接口名 消息发布
调用地址 /api/MqController/sendMsg
参数 actype int 接口类型
uid string 用户id
token string 认证token
msg string 消息
tpcid string 订阅主题id
调用示例 http://localhost:port/api/MqController/sendMsg?actype=10
返回值说明 code:code码
    1:成功;
    2:该用户未订阅任何主题或订阅的主题未包含该主题;
    3:该用户为消费者,无权发布消息
msg:消息
返回值示例 {"code": 1,"msg": "发布成功"}

3.消息获取

接口名 消息获取
调用地址 /api/MqController/getMsg
参数 actype int 接口类型
uid string 认证token
token string 认证token
调用示例 http://localhost:port/api/MqController/getMsg?actype=10
返回值说明 code:code码(100:成功;101:失败)
msg:消息
id:消息id
creattime:创建时间
返回值示例 {
    "code": 100,
    "msg": "消息测试",
    "id": 237,
    "creattime": "2025-03-06T16:30:48"
}

4.查看用户消息队列

接口名 查看用户消息队列
调用地址 /api/MqController/userMsgQueue
参数 actype int 接口类型
uid string 认证token
调用示例 http://localhost:port/api/MqController/userMsgQueue?actype=10
返回值说明 id:消息id(可做序号)
msg:消息内容
tpc_name:主题名称
creattime:创建时间
返回值示例 [
    {
        "msg": "ddddddd1",
        "tpc_name": "主题1",
        "creattime": "2025-03-12 10:47:59",
        "id": 1
    },
    {
        "msg": "ddddddd1",
        "tpc_name": "主题1",
        "creattime": "2025-03-12 10:48:05",
        "id": 2
    }
]

5.用户主题订阅

接口名 查看用户消息队列
调用地址 /api/MqController/subscriptionTopic
参数 actype int 接口类型
uid string 认证token
tpcids string 主题id集合
调用示例 http://localhost:port/api/MqController/subscriptionTopic?actype=10
返回值说明 code:code码(100:成功;101:失败)
msg:消息
返回值示例 {"code": 100,"msg": "订阅成功"}
本文档来自—microbee-http 丨 软件开发框架平台