예제 #1
0
        public PriorityPersistQueue(IQProperties qp)
            : base(qp.QueueName)
        {
            DbLiteSettings settings = new DbLiteSettings()
            {
                Name       = qp.QueueName,
                CommitMode = (CommitMode)(int)qp.CommitMode,
                DbPath     = AgentManager.Settings.QueuesPath
            };

            //settings.SetFast();
            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)
            {
                Logger.Info("PriorityPersistQueue will load items to : {0}", qp.QueueName);
            }
            else
            {
                Logger.Info("PriorityPersistQueue will clear all items from : {0}", qp.QueueName);
            }

            m_db.ReloadOrClearPersist(qp.ReloadOnStart);
        }
예제 #2
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);
                });
            }
        }
예제 #3
0
        public PriorityPersistQueue(IQProperties qp)
            : base(qp.QueueName)
        {
            DbLiteSettings settings = new DbLiteSettings()
            {
                Name       = qp.QueueName,
                CommitMode = (CommitMode)(int)qp.CommitMode,
                DbPath     = AgentManager.Settings.QueuesPath
            };

            m_db = new PersistentQueue(settings);

            // AdapterProperties ap = new AdapterProperties()
            //{
            //    Source = new QueueHost(qp.QueueName, ".", qp.CoverPath, HostAddressTypes.db),
            //    OperationType = AdapterOperations.Sync,
            //    ProtocolType = AdapterProtocols.Db,
            //    ConnectTimeout = qp.ConnectTimeout
            //};
            //m_adapter = new DbAdapter(ap);
        }
예제 #4
0
        public PersistQueue(IQProperties qp)
        {
            int numProcs         = Environment.ProcessorCount;
            int concurrencyLevel = numProcs * 2;
            int initialCapacity  = 101;

            DbLiteSettings settings = new DbLiteSettings()
            {
                Name       = qp.QueueName,
                CommitMode = (CommitMode)(int)qp.CommitMode,
                DbPath     = AgentManager.Settings.QueuesPath
            };

            //settings.SetFast();
            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("PersistQueue will load items to : {0}", qp.QueueName);
            }
            else
            {
                QLogger.InfoFormat("PersistQueue will clear all items from : {0}", qp.QueueName);
            }

            m_db.ReloadOrClearPersist(qp.ReloadOnStart);
        }
예제 #5
0
 public PersistentQueue(DbLiteSettings settings)
     : base(settings)
 {
 }