public static IRabbitExchange DeclareExchange(this IRabbitChannel source, string name, RabbitExchangeType exchangeType) { return(source.DeclareExchange(name, new ExchangeOptions() { ExchangeType = exchangeType, // defaults from the original api: Durable = false, AutoDelete = false })); }
public RabbitProducer(IServiceProvider serviceProvider, string providerName, ISerializer serializer) { this.providerName = providerName; this._serviceProvider = serviceProvider; this._serializer = serializer; this._logger = this._serviceProvider.GetRequiredService <ILogger <RabbitProducer> >(); var channelFactory = serviceProvider.GetRequiredServiceByName <IRabbitChannelFactory>(providerName); this._channel = channelFactory.GetChannel(); }
public RabbitConsumer(IServiceProvider serviceProvider, string providerName, ISerializer serializer) { this.providerName = providerName; this._serviceProvider = serviceProvider; this._serializer = serializer; this._internalConfiguration = serviceProvider.GetRequiredService <IInternalConfiguration>(); this._logger = serviceProvider.GetRequiredService <ILogger <RabbitConsumer> >(); var _channelFactory = serviceProvider.GetRequiredServiceByName <IRabbitChannelFactory>(this.providerName); this._channel = _channelFactory.GetChannel(); }
private void WhenCreateChannel_ConnectionClosed() { try { channel = this.connection.CreateChannel(); } catch (Exception ex) { this.exception = ex; } }
public async Task <IRabbitChannel> GetOrEstablishChannelAsync() { if (channel != null) { return(channel); } await semaphore.WaitAsync(); IsConnecting = true; // check again as another task may have established the channel while we awaited the semaphore if (channel != null) { IsConnecting = false; return(channel); } try { connection = RabbitSetupSetting.GetConnection(options); connection.CallbackException += ConnectionCallbackExceptionHandler; connection.ConnectionRecoveryError += ConnectionRecoveryErrorHandler; var model = RabbitSetupSetting.GetChannel(connection); channel = new RabbitChannel(model, options.Endpoint.Hostname); RabbitSetupSetting.StartExchanges(model, options.Exchanges.Values); return(channel); } catch (BrokerUnreachableException) { //retryTimer.Reset(TimeSpan.FromSeconds(5)); return(null); } finally { IsConnecting = false; semaphore.Release(); } }
public static IRabbitQueueBinding Bind(this IRabbitChannel source, string exchange, string queue, string routingKeyOrFilter) { return((source as IRabbitChannelInternal).BindInternal(false, queue, exchange, routingKeyOrFilter)); }
private void WhenCreateChannel() { channel = this.connection.CreateChannel(); }