private void InternalStop(OperationStopReason reason) { try { this.logger.Trace($"Stopping producer of [{this.Label}]"); this.slimLock.EnterWriteLock(); this.cancellationTokenSource.Cancel(true); this.confirmationTracker?.Dispose(); try { this.Channel.Shutdown -= this.OnChannelShutdown; this.Channel?.Dispose(); } catch (Exception) { // Any channel/model disposal exceptions are suppressed } this.Stopped(this, new ProducerStoppedEventArgs(this, reason)); this.logger.Trace($"Producer of [{this.Label}] stopped successfully"); } finally { try { this.slimLock.ExitWriteLock(); } catch (Exception) { // Suppress all errors } } }
private void InternalStop(OperationStopReason reason) { lock (this.syncRoot) { if (!this.isConsuming) { return; } this.isConsuming = false; this.logger.InfoFormat("Stopping consuming on [{0}].", this.endpoint.ListeningSource); this.cancellationTokenSource.Cancel(true); Task worker; while (this.workers.TryTake(out worker)) { try { worker.Wait(); worker.Dispose(); } catch (Exception) { // May catch OperationCanceledExceptions here on Task.Wait() } } RabbitChannel channel; while (this.channels.TryTake(out channel)) { try { channel.Shutdown -= this.OnChannelShutdown; channel.Dispose(); } catch (Exception) { // Any channel/model disposal exceptions are suppressed } } this.ticketTimer.Dispose(); this.expectations.Values.ForEach(e => e.Cancel()); this.Stopped(this, new ListenerStoppedEventArgs(this, reason)); this.logger.Trace("Listener stopped successfully"); } }
public ProducerStoppedEventArgs(IProducer producer, OperationStopReason reason) { this.Producer = producer; this.Reason = reason; }
public ListenerStoppedEventArgs(IListener listener, OperationStopReason reason) { this.Listener = listener; this.Reason = reason; }