public Task PublishAsync <T>(T message, string messageId = null, string correlationId = null, string spanContext = null, object messageContext = null, IDictionary <string, object> headers = null, IConvention convention = null) where T : class { convention = convention ?? _conventionProvider.Get(message.GetType()); _client.Send(message, convention, messageId, correlationId, spanContext, messageContext, headers); return(Task.CompletedTask); }
public IBusSubscriber Subscribe <T>(Func <IServiceProvider, T, object, Task> handle) where T : class { var convention = _conventionProvider.Get <T>(); var durable = _options.Queue?.Durable ?? true; var exclusive = _options.Queue?.Exclusive ?? false; var autoDelete = _options.Queue?.AutoDelete ?? false; _channel.QueueDeclare(convention.Queue, durable, exclusive, autoDelete); _channel.QueueBind(convention.Queue, convention.Exchange, convention.RoutingKey); _channel.BasicQos(_qosOptions.PrefetchSize, _qosOptions.PrefetchCount, _qosOptions.Global); var consumer = new AsyncEventingBasicConsumer(_channel); consumer.Received += async(sender, args) => await ReceivedMessage <T>(sender, args, handle); _channel.BasicConsume(convention.Queue, false, consumer); return(this); }
/// <summary> /// Executes the register. /// </summary> /// <param name="provider">The provider.</param> /// <param name="context">The context.</param> public static void Register <TContext, TContribution, TDelegate>( [NotNull] IConventionProvider provider, [NotNull] IConventionContext context ) where TContext : IConventionContext where TContribution : IConvention <TContext> where TDelegate : Delegate { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } Register( context, provider.Get <TContribution, TDelegate>(context.GetHostType()), new[] { typeof(TContribution), typeof(TDelegate) } ); }