protected override void BasicPublish( IModel channel, string exchange, string routingKey, bool mandatory, IBasicProperties basicProps, byte[] body, IPipeContext context) { var policy = context.GetPolicy(PolicyKeys.BasicPublish); var policyTask = policy.ExecuteAsync( action: () => { base.BasicPublish(channel, exchange, routingKey, mandatory, basicProps, body, context); return(Task.FromResult(true)); }, contextData: new Dictionary <string, object> { [RetryKey.PipeContext] = context, [RetryKey.ExchangeName] = exchange, [RetryKey.RoutingKey] = routingKey, [RetryKey.PublishMandatory] = mandatory, [RetryKey.BasicProperties] = basicProps, [RetryKey.PublishBody] = body, }); policyTask.ConfigureAwait(false); policyTask.GetAwaiter().GetResult(); }
protected override async Task <Acknowledgement> AcknowledgeMessageAsync(IPipeContext context) { var policy = context.GetPolicy(PolicyKeys.MessageAcknowledge); var result = await policy.ExecuteAsync( action : () => Task.FromResult(base.AcknowledgeMessageAsync(context)), contextData : new Dictionary <string, object> { [RetryKey.PipeContext] = context }); return(await result); }
protected override Task InvokeMessageHandler(IPipeContext context, CancellationToken token) { var policy = context.GetPolicy(PolicyKeys.HandlerInvocation); return(policy.ExecuteAsync( action: ct => base.InvokeMessageHandler(context, ct), cancellationToken: token, contextData: new Dictionary <string, object> { [RetryKey.PipeContext] = context, [RetryKey.CancellationToken] = token })); }
protected override Task DeclareQueueAsync(QueueDeclaration queue, IPipeContext context, CancellationToken token) { var policy = context.GetPolicy(PolicyKeys.QueueDeclare); return(policy.ExecuteAsync( action: ct => base.DeclareQueueAsync(queue, context, ct), cancellationToken: token, contextData: new Dictionary <string, object> { [RetryKey.TopologyProvider] = Topology, [RetryKey.QueueDeclaration] = queue, [RetryKey.PipeContext] = context, [RetryKey.CancellationToken] = token, })); }
protected override Task <IModel> CreateChannelAsync(IPipeContext context, CancellationToken token) { var policy = context.GetPolicy(PolicyKeys.ChannelCreate); return(policy.ExecuteAsync( action: ct => base.CreateChannelAsync(context, ct), cancellationToken: token, contextData: new Dictionary <string, object> { [RetryKey.PipeContext] = context, [RetryKey.CancellationToken] = token, [RetryKey.ChannelFactory] = ChannelFactory } )); }
protected override Task <IBasicConsumer> GetOrCreateConsumerAsync(IPipeContext context, CancellationToken token) { var policy = context.GetPolicy(PolicyKeys.QueueDeclare); return(policy.ExecuteAsync( action: ct => base.GetOrCreateConsumerAsync(context, ct), cancellationToken: token, contextData: new Dictionary <string, object> { [RetryKey.PipeContext] = context, [RetryKey.CancellationToken] = token, [RetryKey.ConsumerFactory] = ConsumerFactory, } )); }
protected override Task BindQueueAsync(string queue, string exchange, string routingKey, IPipeContext context, CancellationToken token) { var policy = context.GetPolicy(PolicyKeys.QueueBind); return(policy.ExecuteAsync( action: ct => base.BindQueueAsync(queue, exchange, routingKey, context, ct), cancellationToken: token, contextData: new Dictionary <string, object> { [RetryKey.TopologyProvider] = TopologyProvider, [RetryKey.QueueName] = queue, [RetryKey.ExchangeName] = exchange, [RetryKey.RoutingKey] = routingKey, [RetryKey.PipeContext] = context, [RetryKey.CancellationToken] = token } )); }