public IMessage GetNext() { var message = this.Repository.Get(); var batch = new Batch(); WebHeaderCollection headers = null; var count = 0; long size = 0; long maxMessagesCount = this.BatchConfiguration.BatchMessageCount; long maxBatchSize = this.BatchConfiguration.BatchMessagesSize; while (message != null && count < maxMessagesCount && size < maxBatchSize) { headers = message.Headers; batch.Add(message); size = this.GetSize(batch); count++; message = this.Repository.GetNextMessageAfter(message.Id); } if (size > maxBatchSize) { batch.RemoveLastMessage(); } if (batch.Events.Count > 0) { var lastMessage = batch.Events[batch.Events.Count - 1]; var batchMessage = new Message(this.GetBatchUploadUrl(lastMessage.Url), batch.ToJson()); batchMessage.Id = lastMessage.ReynaId; for (int index = 0; index < headers.Count; index++) { batchMessage.Headers.Add(headers.Keys[index], headers[index]); } return batchMessage; } return null; }
private IMessage CreateFromDataReader(DbDataReader reader) { if (!reader.HasRows) { return null; } var id = Convert.ToInt32(reader["id"]); var url = new Uri(reader["url"] as string); var body = reader["body"] as string; var message = new Message(url, body) { Id = id }; return message; }
private void putMessageFromFile(IReyna reynaStore, string path, int numberOfMessages) { var body = Read(Path.Combine(path, "test.xml")); for (var index = 0; index < numberOfMessages; index++ ) { var message = new Message(new Uri("https://elemez.com"), body); reynaStore.Put(message); } }
private IMessage GetMessage(string url, string body) { var message = new Message(new Uri(url), body); message.Headers.Add("Content_Type", "application/josn"); message.Headers.Add("PARAM", "VALUE"); return message; }
private void putMessageFromFile(IReyna reynaStore, string path, int numberOfMessages) { var body = Read(Path.Combine(path, "test.xml")); for (var index = 0; index < numberOfMessages; index++ ) { var message = new Message(new Uri("https://elemez.com"), body); reynaStore.Put(message); } while (((ReynaService)reynaStore).VolatileStore.Get() != null) { System.Threading.Thread.Sleep(3 * 1000); } }