当前位置:网站首页>Module VIII

Module VIII

2022-06-12 14:38:00 InfoQ

Self developed message queue storage -- Message table design

1. Each queue has a separate message table , Prevent the read-write interaction of queues , It also avoids the problem of too much data in a single table
Such as queue queue-01
queue_01_message   q01 The message list of
Key table fields :
Id                   news id           Self increasing + Indexes
Header           The message header
Body               Message body
createTm        Creation time


queue_consumer  Queue consumption table
Key table fields :
Id                             Primary key
Consumer_group    Message group id  Indexes
Queue_id                 queue id         Indexes
Offset                       Read offset

Different consumerGroup You can subscribe to the same queue , You need to record the current consumption of each queue offset
Every time a message is read , First query the current consumerGroup The queue to be read id Of offset,offset Is the maximum message consumed in the queue message table id, And then according to offset The query message table is larger than offset The news of
原网站

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206121429466696.html