public RabbitMQProducer( IOptions <RabbitMQOptions> options, IRabbitMQChannelProvider channelProvider) { this.options = options.Value; this.channelProvider = channelProvider; }
public RabbitMQExchangeHostedService( IOptions <RabbitMQOptions> options, IRabbitMQConnectionProvider connectionProvider) { this.options = options.Value; this.connectionProvider = connectionProvider; }
public static RabbitMQOptions UseConnectionFactory( this RabbitMQOptions options, Action <ConnectionFactory> factory) { factory(options.ConnectionFactory); return(options); }
public RabbitMQConnectionProvider(IServiceProvider serviceProvider) { connections = new ConcurrentDictionary <string, RabbitMQConnection>(); options = serviceProvider.GetRequiredService <IOptions <RabbitMQOptions> >().Value; channelLogger = serviceProvider.GetService <ILogger <RabbitMQChannel> >(); connectionLogger = serviceProvider.GetService <ILogger <RabbitMQConnection> >(); }
public RabbitMQConsumerHostedService( IServiceProvider serviceProvider, IOptions <RabbitMQOptions> options, IRabbitMQConnectionProvider connectionProvider) { this.options = options.Value; this.serviceProvider = serviceProvider; this.connectionProvider = connectionProvider; }
public static RabbitMQOptions UseSerialization( this RabbitMQOptions options, Func <object, byte[]> serializer, Func <byte[], Type, object> deserializer) { options.Serializer = serializer; options.Deserializer = deserializer; return(options); }
public RabbitMQConsumer( IModel channel, RabbitMQOptions options, IServiceProvider serviceProvider, RabbitMQConsumerDeclaration declaration, CancellationToken cancellationToken) : base(channel) { this.options = options; this.declaration = declaration; this.cancellationToken = cancellationToken; this.serviceProvider = serviceProvider; }
// Consumers public void BasicConsume( IServiceProvider serviceProvider, RabbitMQOptions options, RabbitMQQueueDeclaration queue, RabbitMQConsumerDeclaration declaration, CancellationToken cancellationToken) { lock (@lock) { for (var index = 0; index < declaration.Count; index++) { channel.BasicConsume( queue: queue.Name, autoAck: declaration.AutoAck, consumerTag: declaration.Tag is null ? string.Empty : $"{declaration.Tag}_{index}", noLocal: declaration.NoLocal, exclusive: declaration.Exclusive, arguments: declaration.Arguments, consumer: new RabbitMQConsumer(channel, options, serviceProvider, declaration, cancellationToken)); } } }
public static RabbitMQOptions UseClientProvidedName( this RabbitMQOptions options, string clientProvidedName) { return(options.UseConnectionFactory(factory => factory.ClientProvidedName = clientProvidedName)); }
public static RabbitMQOptions UseConnectionUrl( this RabbitMQOptions options, string url) { return(options.UseConnectionFactory(factory => factory.Uri = new Uri(url))); }