public void SetSelector(TQItemSelector selector) { this.selector = selector; this.QueryFeature = MongoSelector.GetQuery(this.selector); this.SortFeature = MongoSelector.GetSort(this.selector); OptimiseForSelector(); }
public void OptimiseForSelector() { CheckConnection(); try { Collection.EnsureIndex(MongoSelector.GetIndex(selector)); } catch (MongoConnectionException e) { throw new QueueConnectionException("can't ensure index", e); } }
public TaskMessage GetItemFifo() { CheckConnection(); TaskQueue.TQItemSelector selector = TaskQueue.TQItemSelector.DefaultFifoSelector; var cursor = Collection.Find(MongoSelector.GetQuery(selector)).SetSortOrder(); cursor.Limit = 1; MongoMessage mms = cursor.FirstOrDefault(); if (mms == null)//empty { return(null); } TaskMessage msg = new TaskMessage(mms.ExtraElements); msg.Holder.Add("_id", mms.id.Value); return(msg); }