title: Azure Queue client Dependency injection
body: <p>I have an azure application developed using MVC Web API, and it uses Ninject as the dependency injection framework, here there are number of queues used to communicate with the other worker roles responsible for the background processing.</p>
  
  <p>To be able to unit test I decided to wrap the QueueClient with class called QueueClientWrapper and use an interface named IQueueClientWrapper</p>
  
  <p>the class and interface looks like follows,</p>
  
  <pre><code>public interface IQueueClientWrapper
  {
      void Send&lt;T&gt;(T message);
  }
  
  public class QueueClientWrapper : IQueueClientWrapper
  {
      private QueueClient _queueClient;
  
      public QueueClientWrapper(QueueClient queueClient)
      {
          _queueClient = queueClient;
      }
  
      public void Send&lt;T&gt;(T message)
      {
          _queueClient.Send(new BrokeredMessage(message));
      }
  }
  </code></pre>
  
  <p>However the limitation of this approach is I need to pass the QueueClient into the constructor, which is not possible with the Ninject.</p>
  
  <p>So I was thinking changing the interface like,</p>
  
  <pre><code>public interface IQueueClientWrapper
  {
      void Send&lt;T&gt;(string connectionString,string queueName,T message);
  }
  </code></pre>
  
  <p>so that I can use Ninject to inject the QueueClientWrapper without needing to pass constructor argument, </p>
  
  <p>The issue I have now is, usually it's not recommended to create multiple queue client objects and we have to re-use same instance. So what's the best way to address this (I thought of using a static Hashtable and use to store queue name, queue client pairs, but I'm not very happy with that approach either)? </p>