async Task IEventProcessor.ProcessEventsAsync(PartitionContext context, IEnumerable<EventData> messages) { var iDbService = new DbService(); _client = iDbService.GetFirebaseClient(); foreach (EventData eventData in messages) { string data = Encoding.UTF8.GetString(eventData.GetBytes()); FirebaseResponse response = await _client.PushAsync("event", new EHdata { offset = eventData.Offset, body = data, partitionId = context.Lease.PartitionId }); Console.WriteLine(String.Format("Message received. Partition: '{0}', Data: '{1}', Offset: '{2}'", context.Lease.PartitionId, data, eventData.Offset)); } //Call checkpoint every 5 minutes, so that worker can resume processing from the 5 minutes back if it restarts. if (this.checkpointStopWatch.Elapsed > TimeSpan.FromMinutes(5)) { Console.WriteLine(this.checkpointStopWatch.Elapsed); await context.CheckpointAsync(); this.checkpointStopWatch.Restart(); } }
public ProcessMessage(DbService iDbService, QueueService iQueueService) { _documentClient = iDbService.GetDocumentClient(); _client = iDbService.GetFirebaseClient(); _documentCollection = iDbService.GetDc("LMSCollection", "LMSRegistry"); _sp = iDbService.GetSp(_documentCollection, "Post"); _queue = iQueueService.GetQueue("queue"); }
public static void TableDemo() { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString); CloudTableClient c = storageAccount.CreateCloudTableClient(); CloudTable table = c.GetTableReference("Chat"); table.CreateIfNotExists(); IDbService i = new DbService(); _firebaseClient = i.GetFirebaseClient(); //Search3(table); //Search2(table); //Search3(table); Insert(table).Wait(); //BackupDocumentChat(table).Wait(); }
// This function will get triggered/executed when a new message is written // on an Azure Queue called queue. static Functions() { var iDbService = new DbService(); var iQueueService=new QueueService(); _iProcessMessage = new ProcessMessage.ProcessMessage(iDbService, iQueueService); }