Example #1
0
        public PriorityFsQueue(IQProperties qp)
            : base(qp.QueueName)
        {
            int numProcs         = Environment.ProcessorCount;
            int concurrencyLevel = numProcs * 2;
            int initialCapacity  = 101;

            QueueList = new ConcurrentDictionary <Ptr, IQueueItem>(concurrencyLevel, initialCapacity);

            CommitMode = (CommitMode)(int)qp.CommitMode;
            CoverMode  = qp.Mode;

            if (CoverMode == CoverMode.FileStream)
            {
                DbLiteSettings settings = new DbLiteSettings()
                {
                    Name       = qp.QueueName,
                    CommitMode = (CommitMode)(int)qp.CommitMode,
                    DbPath     = AgentManager.Settings.QueuesPath
                };
                //settings.SetFast();
                QueueHost queueHost = qp.GetRoutHost();
                m_fs = new FileMessage(queueHost);

                //m_db = new PersistentBinary<IQueueItem>(settings);
                ////m_db = new PersistentDictionary(settings);
                //m_db.BeginLoading += M_db_BeginLoading;
                //m_db.LoadCompleted += M_db_LoadCompleted;
                //m_db.ErrorOcurred += M_db_ErrorOcurred;
                //m_db.ClearCompleted += M_db_ClearCompleted;
                ////m_db.ItemChanged += M_db_ItemChanged;

                //m_db.ItemLoaded = (item) =>
                //{
                //    this.ReEnqueue(item);
                //};

                if (qp.ReloadOnStart)
                {
                    QLogger.InfoFormat("PriorityComplexQueue will load items to : {0}", qp.QueueName);
                }
                else
                {
                    QLogger.InfoFormat("PriorityComplexQueue will clear all items from : {0}", qp.QueueName);
                }

                //m_db.ReloadOrClearPersist(qp.ReloadOnStart);

                m_fs.ReloadItemsTo(0, (IQueueItem item) =>
                {
                    this.ReEnqueue(item);
                });
            }
        }