コード例 #1
0
        public MongoQueue(MongoQueConfig config)
        {
            // our queue name will be the same as the message class
            _database = MongoDatabase.Create(config.ConnectionString);

            if (!_database.CollectionExists(_queueName))
            {
                try
                {
                    Log.InfoFormat("Creating queue '{0}' size {1}", _queueName, config.QueueSize);

                    var options = CollectionOptions
                                  .SetCapped(true)               // use a capped collection so space is pre-allocated and re-used
                                  .SetAutoIndexId(true)
                                  .SetMaxSize(config.QueueSize); // limit the size of the collection and pre-allocated the space to this number of bytes

                    _database.CreateCollection(_queueName, options);
                    var col = _database.GetCollection(_queueName);
                    col.EnsureIndex(new[] { "Dequeued" });
                    col.EnsureIndex(new[] { "Equeued" });
                }
                catch
                {
                    // assume that any exceptions are because the collection already exists ...
                }
            }

            // get the queue collection for our messages
            _queue = _database.GetCollection <MongoMessage <T> >(_queueName);
        }
コード例 #2
0
ファイル: MongoPubSubClient.cs プロジェクト: DanamoCP/monQue
 public MongoPubSubClient(MongoQueConfig config) : base(config)
 {
 }
コード例 #3
0
ファイル: MongoWorker.cs プロジェクト: DanamoCP/monQue
 public MongoWorker(MongoQueConfig config) : base(config)
 {
 }