Atitit. Improving software stability---persistent cyclic queue based on database implementation ring queue

Source: Internet
Author: User
Tags addall

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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.