当前位置:网站首页>模块八作业
模块八作业
2022-06-11 19:31:00 【InfoQ】
- 不同任务的队列建不同的表,比如xx_q, yy_q等。这样可以减少每个消息表的大小,提高性能;减少不同消息之间的干扰,提高SQL执行速度。
- 表结构
CREATE TABLE `xx_q` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `status` tinyint(4) DEFAULT 0, `ps` int(11) DEFAULT 0, `ut` timestamp, `msg` json, PRIMARY KEY (`id`), KEY `ut` (`ps`,`status`)) - 工作原理:
- 锁定本次工作消息: update xx_q set ps=connection_id() , status=1 where ps = 0 and status=0 limit 1;
- 获取消息体: select id, msg from xx_q where ps = connection_id() and status=1;
- 进行 消息消费
- 删除消费完毕的消息 delete from xx_q where ps = connection_id() and status=1;
- 清理僵尸进程占据的消息:定时清除 会话id 已经不存在(异常退出)但status=1 且 僵尸时间超过30分钟的消息
边栏推荐
- PyMySQL利用游标操作数据库方法封装!!!
- Practice of tag recognition based on Huawei cloud image
- Big work and requirements of economics in autumn 21 of Dagong [standard answer]
- 【Bug解决】UnpicklingError: A load persistent id instruction was encountered, but no persistent_load.
- [C language questions -- 10 simple questions for leetcode]
- 程序员10年巨变,一切都变了又好像没变...
- Go语言入门(六)——循环语句
- [untitled]
- [image segmentation] image segmentation based on Markov random field with matlab code
- How are functional components different from class components
猜你喜欢
【求助】请问如何让微信公众号文章在外部浏览器中打开后还能显示下方的精选留言?

Anaconda installation, jupyter notebook default startup path modification and nbextensions plug-in installation

30讲 线性代数第二讲 矩阵

Multimodal learning toolkit paddlemm based on propeller

干货!基于序列超图神经网络的信息扩散预测

图床:PicGo+腾讯云+typora

This article introduces you to the infrastructure of sofaregistry
![[signal denoising] speech adaptive denoising based on nonlinear filter with matlab code](/img/fd/07cee3c51ac44ca40f730dd487aa20.png)
[signal denoising] speech adaptive denoising based on nonlinear filter with matlab code

【图像去噪】基于绝对差分中值滤波、加权中值滤波法、改进加权中值滤波实现脉冲噪声图像去噪附matlab代码
[help] how can wechat official account articles be opened in an external browser to display the selected messages below?
随机推荐
我不太想在网上开户,网上股票开户安全吗?
Pyramid test principle: 8 tips for writing unit tests
Hyper parameter optimization of deep neural networks using Bayesian Optimization
[image segmentation] image segmentation based on Markov random field with matlab code
Merge multiple binary search trees
CMU 15-445 database course lesson 5 text version - buffer pool
Yolov3 pytoch code and principle analysis (II): network structure and loss calculation
Judge whether it is a balanced binary tree
Common - name of conference room
【 aide 】 comment puis - je faire en sorte que les messages sélectionnés ci - dessous puissent être affichés après l'ouverture de l'article Wechat public number dans un navigateur externe?
干货!基于序列超图神经网络的信息扩散预测
无监督图像分类《SCAN:Learning to Classify Images without》代码分析笔记(1):simclr
Specific methods for porting WinCC flexible 2008 project to botu WinCC
SISO decoder for SPC (supplementary Chapter 1)
Introduction to go language (V) -- branch statement
Web3 Games: exploring and reshaping the game experience
What started mongodb? What are the application scenarios?
[image denoising] image denoising based on Markov random field with matlab code
Introduction to go language (VI) -- loop statement
Bottomsheetdialog usage details, setting fillet, fixed height, default full screen, etc