现在的位置: 首页 > 综合 > 正文

Mysql Q4M 队列操作封装(三)

2013年09月01日 ⁄ 综合 ⁄ 共 632字 ⁄ 字号 评论关闭

public class AuditQ4M : MyQ4M<AuditQueue>
    {
        public AdQ4M(string connectionKey) : base(connectionKey)
        {
        }

        protected override string GetItemSql()
        {
            const string strSql = "SELECT * FROM empqe.`audit_queue` WHERE queue_wait('audit_queue:xx = 2',2);";

            return strSql;
        }

    }

具体业务类的扩展只需要实现GetItemSql() ,写上具体的获取队列第一条数据Sql即可

实际使用如下:

var que = new AuditQ4M ("luyifeng_qe_key");

            try
            {
                while (true)
                {
                    var queItem= que.First();
                    if (queItem== null)
                    {
                        break;
                    }

 //to do ……

                    que.Remove();
                }

            }
            catch (Exception ex)
            {
                que.Rollback();
                //to do ……
            }

抱歉!评论已关闭.