public void RemoveAmqpUnit(AmqpUnit amqpUnit) { amqpUnit.Dispose(); IAmqpUnitManager amqpConnectionPool = ResolveConnectionPool(amqpUnit.GetDeviceIdentity().IotHubConnectionString.HostName); amqpConnectionPool.RemoveAmqpUnit(amqpUnit); }
public void RemoveAmqpUnit(AmqpUnit amqpUnit) { if (Logging.IsEnabled) { Logging.Enter(this, amqpUnit, $"{nameof(RemoveAmqpUnit)}"); } DeviceIdentity deviceIdentity = amqpUnit.GetDeviceIdentity(); if (deviceIdentity.IsPooling()) { AmqpConnectionHolder amqpConnectionHolder; lock (_lock) { AmqpConnectionHolder[] amqpConnectionHolders = ResolveConnectionGroup(deviceIdentity); amqpConnectionHolder = ResolveConnectionByHashing(amqpConnectionHolders, deviceIdentity); } amqpConnectionHolder.RemoveAmqpUnit(amqpUnit); } if (Logging.IsEnabled) { Logging.Exit(this, amqpUnit, $"{nameof(RemoveAmqpUnit)}"); } }
public void RemoveAmqpUnit(AmqpUnit amqpUnit) { if (Logging.IsEnabled) { Logging.Enter(this, amqpUnit, nameof(RemoveAmqpUnit)); } IDeviceIdentity deviceIdentity = amqpUnit.GetDeviceIdentity(); if (deviceIdentity.IsPooling()) { AmqpConnectionHolder amqpConnectionHolder; lock (_lock) { AmqpConnectionHolder[] amqpConnectionHolders = ResolveConnectionGroup(deviceIdentity); amqpConnectionHolder = ResolveConnectionByHashing(amqpConnectionHolders, deviceIdentity); amqpConnectionHolder.RemoveAmqpUnit(amqpUnit); // If the connection holder does not have any more units, the entry needs to be nullified. if (amqpConnectionHolder.IsEmpty()) { int index = GetDeviceIdentityIndex(deviceIdentity, amqpConnectionHolders.Length); amqpConnectionHolders[index] = null; amqpConnectionHolder?.Dispose(); } } } if (Logging.IsEnabled) { Logging.Exit(this, amqpUnit, nameof(RemoveAmqpUnit)); } }