Atitit. Improving software stability---persistent cyclic queue based on database implementation ring queue
1. Preface:: Selection (horse) 1
2. Implementing the Java.util.queue Interface 1
3.2 implementations of the current pointer 1
1.1. With a cursor last to indicate (the Pointer table field last), troublesome, not recommended 1
1.2. (Simple, recommended) use the number of cycles to indicate that each loop adds 1 (field cirtimes), ORDER by Cirtimes 1
4. Table Design ID, Cirtimes,createtime,handlerid,recid,delflag 1
5. Circular queue Loop Queue usage Flow 2
1.3. Join the queue Addall,add 2
1.4. Grab the element to be processed peek (int fetchcount) Delflag=0,order by Cirtimes 2
1.5. Out of the squad and append to the end of the team Remove,removeall (list)::: cirtimes++; 2
1. Preface:: Selection (horse)
Pick a Li Yiwa, a implet for the horse
In order to use the loop queue, the stability of the queue can be greatly improved. Prevent push message outdate not send ... and avoid the queue to get stuck
2. implement the Java.util.queue interface
3. 2 implementations of the current pointer
1.1. with a cursor last to indicate (the Pointer table field last), troublesome, not recommended 1.2. (simple, recommended) use the number of cycles to indicate that each loop adds 1 (field cirtimes), and order by Cirtimes
Author:: Old Wow's paw Attilax Ayron, email:1466519819@qq.com
Reprint please indicate source: Http://blog.csdn.net/attilax
4. table Design ID, cirtimes,createtime,handlerid,recid,delflag
ID, Cirtimes,createtime,handlerid,recid,delflag
Handlerid:: You can make many processors available, each processor only get its own queue.
recid:: Associated Rec ID ... 5. Circular Queue loop Queue usage Flow 1.3. Join queue Addall,add
1.4. Grab the element to be processed peek (int fetchcount) Delflag=0,order by Cirtimes
Public List Peek (int fetchcount) {
Attilax's Paw M_9_r o7s
Final List li=new ArrayList ();
Noticeflag is null
String hql= "from Gvdownloadtask where 1=1 and downloadstatus are null order by Noticeflag";
Query q = getsession (). CreateQuery (HQL);
Q.setfirstresult (0);
Q.setmaxresults (Fetchcount);
List L = q.list ();
return l;
} 1.5. and append to the end of the team Remove,removeall (list)::: cirtimes++;
T.setnoticeflag (T.getnoticeflag () +1);
C.merge (t);