public EventHubClient GetEventHubClient() { if (_messageFactoryPool.Count > 0) { int mfpPoolIx = new Random().Next(_messageFactoryPool.Count); MessagingFacotryPoolItem mfpi = _messageFactoryPool[mfpPoolIx]; return(mfpi.GetRandomEventHubClient()); } else { return(null); } }
public void InitPool() { _messageFactoryPool = new List <MessagingFacotryPoolItem>(); try { for (int i = 0; i < _numMessagingFactories; i++) { MessagingFacotryPoolItem mf = new MessagingFacotryPoolItem(_sbConnectionString, _eventHubName, _numEventHubClients); _messageFactoryPool.Add(mf); } _poolInitialized = true; } catch (ApplicationException ex) { throw new ApplicationException("InitPool exception", ex); } }