您的位置:首页 > 博客中心 > 数据库 >

Atitit.提升软件稳定性---基于数据库实现的持久化 循环队列 环形队列

时间:2022-03-13 22:36

Atitit.提升软件稳定性---基于数据库实现的持久化  循环队列 环形队列

 

 

 

1. 前言::选型(马)

挑选李一瓦,马个适合的implet

为甚要使用循环队列 ,,可以大的提升队列的稳定性..防止推送消息outdate不送...and避免队列卡住

 

2. 实现java.util.queue接口

 

 

3. 当前指针的2个实现方式

 

1.1. 用一个游标last 来指示 (指针表字段last ),麻烦的,不推荐

1.2. (简单,推荐)使用循环次数来指示,每循环加1   (字段cirTimes),order by cirtimes

作者::老哇的爪子Attilax艾龙,EMAIL:1466519819@qq.com

转载请注明来源: http://blog.csdn.net/attilax

 

4. 表格设计id, cirTimes,createtime,handlerID,recID,delFlag

id, cirTimes,createtime,handlerID,recID,delFlag

 

handlerID::可以让许多的处理器使用,每个processor只获得自己的队列..

recid::关联的rec id...

5. 循环队列 环形队列使用流程

1.3. 加入队列addALL,add

 

1.4. 抓取要处理的元素 peek(int fetchCount)  delFlag=0,order by cirtimes

 

public List peek(int fetchCount) {

// attilax 老哇的爪子  m_9_r   o7s 

final List li=new ArrayList();

//  noticeFlag is null

String hql="from GvDownloadTask   where 1=1 and downloadStatus is null   order by noticeFlag  ";

Query q = getSession().createQuery(hql); 

q.setFirstResult(0); 

q.setMaxResults(fetchCount); 

List l = q.list(); 

return l;

 

}

1.5.  

t.setNoticeFlag(t.getNoticeFlag()+1);

c.merge(t);

 

Atitit.提升软件稳定性---基于数据库实现的持久化 循环队列 环形队列,布布扣,bubuko.com

热门排行

今日推荐

热门手游