private bool ShouldDeliverBatch(StreamId streamId, IBatchContainer batchContainer, string filterData) { if (this.streamFilter is NoOpStreamFilter) { return(true); } try { foreach (var evt in batchContainer.GetEvents <object>()) { if (this.streamFilter.ShouldDeliver(streamId, evt.Item1, filterData)) { return(true); } } return(false); } catch (Exception exc) { var message = $"Ignoring exception while trying to evaluate subscription filter '{this.streamFilter.GetType().Name}' with data '{filterData}' on stream {streamId}"; logger.Warn((int)ErrorCode.PersistentStreamPullingAgent_13, message, exc); } return(true); }
public async Task <StreamHandshakeToken> DeliverBatch(IBatchContainer batch, StreamHandshakeToken handshakeToken) { // we validate expectedToken only for ordered (rewindable) streams if (expectedToken != null) { if (!expectedToken.Equals(handshakeToken)) { return(expectedToken); } } if (batch is IBatchContainerBatch) { var batchContainerBatch = batch as IBatchContainerBatch; await NextBatch(batchContainerBatch); } else { foreach (var itemTuple in batch.GetEvents <T>()) { await NextItem(itemTuple.Item1, itemTuple.Item2); } } if (IsRewindable) { expectedToken = StreamHandshakeToken.CreateDeliveyToken(batch.SequenceToken); } return(null); }
public async Task DeliverBatch(IBatchContainer batch) { foreach (var itemTuple in batch.GetEvents <T>()) { await DeliverItem(itemTuple.Item1, itemTuple.Item2); } }
public async Task <StreamSequenceToken> DeliverBatch(IBatchContainer batch, StreamSequenceToken prevToken) { if (expectedToken != null) { if (!expectedToken.Equals(prevToken)) { return(expectedToken); } } foreach (var itemTuple in batch.GetEvents <T>()) { await NextItem(itemTuple.Item1, itemTuple.Item2); } // check again, in case the expectedToken was changed indiretly via ResumeAsync() if (expectedToken != null) { if (!expectedToken.Equals(prevToken)) { return(expectedToken); } } expectedToken = batch.SequenceToken; return(null); }
public async Task <StreamSequenceToken> DeliverBatch(IBatchContainer batch) { foreach (var itemTuple in batch.GetEvents <T>()) { var newToken = await DeliverItem(itemTuple.Item1, itemTuple.Item2); if (newToken != null) { return(newToken); } } return(default(StreamSequenceToken)); }
public Task Write(IBatchContainer batchContainer) { var count = batchContainer .GetEvents <object>() .Count(); _logger.LogInformation( "Received message: Batch container created {@trackingUnit} with {count} event(s)", batchContainer, count ); return(Task.CompletedTask); }
public Task Write(IBatchContainer batchContainer) { var messageIndex = 0; var events = batchContainer .GetEvents <string>() .ToDictionary(@event => $"event{messageIndex++}", @event => @event.Item1); using (_logger.BeginScope(events)) { _logger.LogInformation("Received message: Batch container created {@messageBatch}", batchContainer); } return(Task.CompletedTask); }
public async Task <StreamHandshakeToken> DeliverBatch(IBatchContainer batch, StreamHandshakeToken handshakeToken) { if (expectedToken != null) { if (!expectedToken.Equals(handshakeToken)) { return(expectedToken); } } foreach (var itemTuple in batch.GetEvents <T>()) { await NextItem(itemTuple.Item1, itemTuple.Item2); } expectedToken = StreamHandshakeToken.CreateDeliveyToken(batch.SequenceToken); return(null); }