CREATE TABLE `queue` (
`id` bigint(20) NOT NULL COMMENT '主键',
`name` varchar(64) COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT '队列名称',
PRIMARY KEY (`id`),
UNIQUE KEY `ix_u_name` (`name`) USING HASH COMMENT '队列名称唯一索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci COMMENT='队列';
CREATE TABLE `<queue_name>_message` (
`id` bigint(20) NOT NULL COMMENT '主键',
`content` varchar(1024) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL COMMENT '消息体',
`produced_by` varchar(64) COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT '生产者',
PRIMARY KEY (`id`),
KEY `ix_produced_by` (`produced_by`) USING BTREE COMMENT '消费者索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci COMMENT='消息';
CREATE TABLE `<queue_name>_message_consumed` (
`id` bigint(20) NOT NULL COMMENT '主键',
`message_id` bigint(20) NOT NULL COMMENT '消息主键',
`consumed_by` varchar(64) COLLATE utf8mb4_unicode_520_ci NOT NULL COMMENT '消费者',
`state` tinyint(2) NOT NULL COMMENT '消费状态 0已发送尚未消费 1消费成功 2消费失败',
PRIMARY KEY (`id`),
KEY `ix_message_id` (`message_id`) USING BTREE COMMENT '消息主键索引',
KEY `ix_consumed_by` (`consumed_by`) USING BTREE COMMENT '消费者索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci COMMENT='消息消费记录';
评论