public async Task PullAll() { var start = LocalTime.Now; await PublishQueue.PullAll <ReplicateDataMessage>(Import); Log.For(this).Info("Pulled from queue in " + LocalTime.Now.Subtract(start).ToNaturalTime()); }
public static Task PullAll <TMessage>(this IEventBusQueue queue, Func <TMessage, Task> @handler) where TMessage : IEventBusMessage { return(queue.PullAll(message => { if (message.IsEmpty()) { return Task.CompletedTask; } try { var @event = JsonConvert.DeserializeObject <TMessage>(message); return handler(@event); } catch (Exception ex) { throw new Exception("Failed to deserialize event message to " + typeof(TMessage).FullName + ":\r\n" + message, ex); } })); }