public void Push(IJob <IJobData> job) { BsonDocument document = JobSerializer.ToBsonDocument(job); Logging.Log().Debug("Inserting job into MongoDB queue: {document}", JobSerializer.ToJson(job)); var db = this.client.GetDatabase(DatabaseName); var collection = db.GetCollection <BsonDocument>(CollectionName); collection.InsertOne(document); Logging.Log().Debug("{document} inserted into MongoDB queue.", document); }
public void Push(IJob <IJobData> job) { Guid newGuid; do { newGuid = Guid.NewGuid(); }while (jobs.ContainsKey(newGuid)); string json = JobSerializer.ToJson(job); Logging.Log().Debug("Inserting job into FileSystem queue: {json}", json); this.jobs.Add(newGuid, json); string path = Path.Combine(this.queuePath, newGuid.ToString() + ".json"); File.WriteAllText(path, json); }