- class Program
- {
- static void Main(string[] args)
- {
- try
- {
- MainAsync(args).Wait();
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- }
-
-
- Console.WriteLine("Press Enter");
- Console.ReadLine();
- }
-
- static async Task MainAsync(string[] args)
- {
- string uri = "mongodb://Host:27017/Bourse";
- var client = new MongoClient(uri);
- var db = client.GetDatabase("Bourse");
- var col = db.GetCollection<BOSBourse>("Symbole");
-
- var tailer = new Tailer(client);
- IOutlet outlet = new BOSBourse();
- var stream = new Stream(tailer, outlet);
- Oplog lastOplog = await tailer.GetMostRecentOplog();
- await stream.RunForever(lastOplog);
-
- }
-
- private async Task RunStream(Stream stream, Oplog startOplog)
- {
- var task = stream.RunForever(startOplog);
- await Task.WhenAny(task, Task.Delay(5000));
- stream.Stop();
- }
-
- class BOSBourse : IOutlet
- {
- public ObjectId _id { get; set; }
- public String Name { get; set; }
- public Double Price { get; set; }
-
- public void UpdateOptime(BsonTimestamp timestamp)
- {
- throw new NotImplementedException();
- }
-
- public void Insert(string databaseName, string collectionName, BsonDocument insertedDocument)
- {
- throw new NotImplementedException();
- }
-
- public void Update(string databaseName, string collectionName, BsonDocument filterDocument, BsonDocument updatedDocument)
- {
- throw new NotImplementedException();
- }
-
- public void Delete(string databaseName, string collectionName, BsonDocument filterDocument)
- {
- throw new NotImplementedException();
- }
-
- public void CreateIndex(string databaseName, string collectionName, BsonDocument indexDocument, BsonDocument optionsDocument)
- {
- throw new NotImplementedException();
- }
-
- public void DeleteIndex(string databaseName, string collectionName, string indexName)
- {
- throw new NotImplementedException();
- }
-
- public void CreateCollection(string databaseName, string collectionName, BsonDocument optionsDocument)
- {
- throw new NotImplementedException();
- }
-
- public void RenameCollection(string databaseName, string collectionName, string newCollectionName)
- {
- throw new NotImplementedException();
- }
-
- public void DeleteCollection(string databaseName, string collectionName)
- {
- throw new NotImplementedException();
- }
-
- public void DeleteDatabase(string databaseName)
- {
- throw new NotImplementedException();
- }
- }
- }
And it gives me Exceptions:
System.AggregateException: One or more errors occurred. ---> MongoRiver.MongoRiverException: Mongo client is not configured as a replica set at MongoRiver.Tailer..ctor(IMongoClient client, MongoCollectionSettings oplogCollectionSettings, String oplogCollectionName)
Even after I add to the code, I get the same Exception
string uri = "mongodb://Host:27017/?safe=true&connect=replicaset";