public static IDisposable SubscribeOnQueueToMessage <T>(this IObservableConnection connection, ISubscriptionConfig config, IRabbitMessageHandler <T> handler) { return(connection.Queue(config.QueueName) .Open() .Stream <T>() .SubscribeWithAck(rm => { handler.Handle(rm.Message); })); }
public static IDisposable SubscribeOnQueueToMessage <T>(this IObservableConnection connection, IBatchSubscriptionConfig config, IRabbitMessageHandler <IEnumerable <T> > handler) { return(SubscribeWithAck(connection.Queue(config.QueueName) .Open() .Stream <T>() .Buffer(config.BufferTimeout, config.BufferSize) .Where(m => m.Any()) .Select(l => l.AsEnumerable()), l => { var rabbitMessages = l.ToArray(); handler.Handle(rabbitMessages.Select(m => m.Message)); })); }