protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_consumerPool != null) { _consumerPool.Stop(); _consumerPool.Dispose(); _consumerPool = null; } if (_serviceContainer != null) { _serviceContainer.Stop(); _serviceContainer.Dispose(); _serviceContainer = null; } if (ControlBus != this) { ControlBus.Dispose(); } _unsubscribeEventDispatchers(); InboundPipeline.Dispose(); InboundPipeline = null; OutboundPipeline.Dispose(); OutboundPipeline = null; if (_eventAggregatorScope != null) { _eventAggregatorScope.Dispose(); _eventAggregatorScope = null; } _eventAggregator = null; Endpoint = null; if (_counters != null) { _counters.Dispose(); _counters = null; } if (PoisonEndpoint != null) { PoisonEndpoint = null; } } _disposed = true; }
void InitializePerformanceCounters() { try { string instanceName = string.Format("{0}_{1}{2}", Endpoint.Address.Uri.Scheme, Endpoint.Address.Uri.Host, Endpoint.Address.Uri.AbsolutePath.Replace("/", "_")); _counters = new ServiceBusInstancePerformanceCounters(instanceName); _performanceCounterConnection = _eventChannel.Connect(x => { x.AddConsumerOf <MessageReceived>() .UsingConsumer(message => { _counters.ReceiveCount.Increment(); _counters.ReceiveRate.Increment(); _counters.ReceiveDuration.IncrementBy( (long)message.ReceiveDuration.TotalMilliseconds); _counters.ReceiveDurationBase.Increment(); _counters.ConsumerDuration.IncrementBy( (long)message.ConsumeDuration.TotalMilliseconds); _counters.ConsumerDurationBase.Increment(); }); x.AddConsumerOf <MessagePublished>() .UsingConsumer(message => { _counters.PublishCount.Increment(); _counters.PublishRate.Increment(); _counters.PublishDuration.IncrementBy((long)message.Duration.TotalMilliseconds); _counters.PublishDurationBase.Increment(); _counters.SentCount.IncrementBy(message.ConsumerCount); _counters.SendRate.IncrementBy(message.ConsumerCount); }); x.AddConsumerOf <ThreadPoolEvent>() .UsingConsumer(message => { _counters.ReceiveThreadCount.Set(message.ReceiverCount); _counters.ConsumerThreadCount.Set(message.ConsumerCount); }); }); } catch (Exception ex) { _log.Warn( "The performance counters could not be created, try running the program in the Administrator role. Just once.", ex); } }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_consumerPool != null) { _consumerPool.Stop(); _consumerPool.Dispose(); _consumerPool = null; } if (_serviceContainer != null) { _serviceContainer.Stop(); _serviceContainer.Dispose(); _serviceContainer = null; } if (ControlBus != this) { ControlBus.Dispose(); } if (_performanceCounterConnection != null) { _performanceCounterConnection.Dispose(); _performanceCounterConnection = null; } _eventChannel = null; Endpoint = null; if (_counters != null) { _counters.Dispose(); _counters = null; } EndpointCache.Dispose(); } _disposed = true; }
private void InitializePerformanceCounters() { try { var instanceName = string.Format("{0}_{1}_{2}", Endpoint.Address.Path, Endpoint.Uri.Scheme, Endpoint.Uri.Host); _counters = new ServiceBusInstancePerformanceCounters(instanceName); _eventAggregatorScope.Subscribe <MessageReceived>(message => { _counters.ReceiveCount.Increment(); _counters.ReceiveRate.Increment(); _counters.ReceiveDuration.IncrementBy((long)message.ReceiveDuration.TotalMilliseconds); _counters.ReceiveDurationBase.Increment(); _counters.ConsumerDuration.IncrementBy((long)message.ConsumeDuration.TotalMilliseconds); _counters.ConsumerDurationBase.Increment(); }); _eventAggregatorScope.Subscribe <MessagePublished>(message => { _counters.PublishCount.Increment(); _counters.PublishRate.Increment(); _counters.PublishDuration.IncrementBy((long)message.Duration.TotalMilliseconds); _counters.PublishDurationBase.Increment(); _counters.SentCount.IncrementBy(message.ConsumerCount); _counters.SendRate.IncrementBy(message.ConsumerCount); }); _eventAggregatorScope.Subscribe <ThreadPoolEvent>(message => { _counters.ReceiveThreadCount.Set(message.ReceiverCount); _counters.ConsumerThreadCount.Set(message.ConsumerCount); }); } catch (Exception ex) { _log.Warn("The performance counters could not be created", ex); } }