耗时服务
长耗时微服务
mysql数据库
表名: tbl_async_task
id bigint not null 任务id
user_task_id varchar(64) 用户任务id
name varchar(64) not null 任务名称
station_id varchar(16) not null 站点id
input text not null 业务请求输入数据
result json 业务处理结果
status tinyint(4) not null 任务状态, 1-已经提交, 2-正在执行, 3-已经完成
repeat tinyint(1) 是否可重复
message_show tinyint(1) 是否展示
run_count int(11) not null 执行次数
type int not null 任务类型id
creat_time datetime not null 创建时间
modify_time datetime not null 修改时间
start_time datetime 任务开始时间
end_time datetime 任务结束时间
gm_async_task 工程(微服务)
/task/add 任务添加
接口描述: 向数据库中添加添加任务
请求: POST
---- params ----
station_id M str 站点id
task_name M str 任务名称
input M str 请求数据容器
repeat O bool 是否可重复
user_task_id O str 用户任务id
type_id O int 任务id
响应:
code M int 0为成功, 其它为失败
msg M str 错误提示信息
data M json 返回数据容器
{
task_id M int 任务id
user_task_id M str 用户任务id
}
/task/start 任务开始
接口描述: 业务接口必须先调用的任务开始接口
请求: POST
---- params ----
task_id C str 任务id(task_id和user_task_id二选一, 必传)
user_task_id C str 用户任务id
响应:
code M int 0为成功, 其它为失败
msg M str 错误提示信息
data M json 返回数据容器
{
task_id M int 任务id
user_task_id M str 用户任务id
user_task_id M str 用户任务id
status M int 任务状态, 1-已经提交, 2-正在执行, 3-已经完成
create_time M datetime 任务创建时间
modify_time M datetime 任务修改时间
start_time M datetime 任务开始时间
end_time M datetime 任务结束时间
input M text 业务输入数据
result M json 返回数据容器
}
/task/update 更新任务接口
接口描述: 多用于更新任务结果
请求: POST
---- params ----
value M str 修改的值
field M str 更新字段
postion O str 要更新的字段位置(部分更新时候, 索引则 $[index], 值则 $.var)]
task_id C int 任务id
user_task_id C str 用户自定义id
响应:
code M int 0为成功, 其它为失败
msg M str 错误提示信息
data M null 返回数据容器
/task/finish 完成任务接口
接口描述: 多用于关闭任务, 部分请求用于修改任务参数
请求: POST
---- params ----
task_id C int 任务id
user_task_id C str 用户自定义id
响应:
code M int 0为成功, 其它为失败
msg M str 错误提示信息
data M null 返回数据容器
/task/get 单个任务查看
接口描述: 单个任务查看
请求:
---- params ----
task_id C int 任务id
user_task_id C str 用户自定义id
响应:
code M int 0为成功, 其它为失败
msg M str 错误提示信息
data M json 返回数据容器
{
task_id M int 任务id
user_task_id M str 用户任务id
user_task_id M str 用户任务id
status M int 任务状态, 1-已经提交, 2-正在执行, 3-已经完成
task_name M str 任务名称
create_time M datetime 任务创建时间
modify_time M datetime 任务修改时间
start_time M datetime 任务开始时间
end_time M datetime 任务结束时间
input M text 业务输入数据
result M json 返回数据容器
}
/task/list 批量任务查看
接口描述: 单个任务查看
请求:
---- params ----
station_id M str 任务id
status O int 状态
limit M int 数据数目, 默认为10
offset M int 页数, 默认0页
响应:
code M int 0为成功, 其它为失败
msg M str 错误提示信息
data M list 返回数据容器
[{
task_id M int 任务id
user_task_id M str 用户任务id
status M int 任务状态, 1-已经提交, 2-正在执行, 3-已经完成
create_time M datetime 任务创建时间
modify_time M datetime 任务修改时间
start_time M datetime 任务开始时间
end_time M datetime 任务结束时间
input M text 业务输入数据
result M json 返回数据容器
}]
gm_service工程
/async_task/get 单个任务查看
接口描述: 单个任务查看
请求:
---- params ----
task_id C int 任务id
user_task_id C str 用户任务id
响应:
code M int 0为成功, 其它为失败
msg M str 错误提示信息
data M json 返回数据容器
{
task_id M str 任务id
user_task_id O str 用户任务id
status M int 任务状态, 1-已经提交, 2-正在执行, 3-已经完成
create_time M datetime 任务创建时间
modify_time M datetime 任务修改时间
start_time O datetime 任务开始时间
end_time O datetime 任务结束时间
result O json 返回数据容器
}
/station/order/batch/submit 批量提交订单
接口描述: 异步批量提交订单
Method: POST
请求:
---- params ----
task_id M str 任务id
time_config_id M str 运营周期id
order_data M list 订单数据
响应:
code M int 0为成功, 其它为失败
msg M str 错误提示信息
data M json 返回数据容器
{
task_url M str 任务结果返回地址
}
/async_task/detail 任务详情查看
逻辑改为调用微服务, 增加modify_time返回字段, 其余参数和返回不变
/async_task/list 任务列表查看
逻辑改为调用微服务, 每个元素增加modify_time返回字段, 其余参数和返回不变
/async_task/close 关闭任务
逻辑改为调用微服务, 其余无变化
/station/order/batch/amend 修改订单结果
逻辑改为调用微服务, 其余无变化
自定义队列说明
1. 先在gm_task工程中增加你要的队列以及声明该队列的路由键, 通常直连方式下, 路由键和队列名保持一致即可
2. 在具体业务工程的local配置中, 将gm_task_queue改为你定义的即可