File tree Expand file tree Collapse file tree
src/HangFire.Azure.ServiceBusQueue Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,16 +23,26 @@ public ServiceBusManager(ServiceBusQueueOptions options)
2323
2424 _options = options ;
2525
26- _clients = new Dictionary < string , QueueClient > ( ) ;
26+ _clients = new Dictionary < string , QueueClient > ( options . Queues . Length ) ;
2727 _namespaceManager = NamespaceManager . CreateFromConnectionString ( options . ConnectionString ) ;
2828 _messagingFactory = MessagingFactory . CreateFromConnectionString ( options . ConnectionString ) ;
2929
30- CreateQueueClients ( ) ;
30+ // If we have this option set to true then we will create all clients up-front, otherwise
31+ // the creation will be delayed until the first client is retrieved
32+ if ( options . CheckAndCreateQueues )
33+ {
34+ CreateQueueClients ( ) ;
35+ }
3136 }
3237
3338 public QueueClient GetClient ( string queue )
3439 {
35- return this . _clients [ queue ] ;
40+ if ( _clients . Count != _options . Queues . Length )
41+ {
42+ CreateQueueClients ( ) ;
43+ }
44+
45+ return _clients [ queue ] ;
3646 }
3747
3848 public QueueDescription GetDescription ( string queue )
Original file line number Diff line number Diff line change @@ -27,6 +27,11 @@ public ServiceBusQueueOptions()
2727 /// Gets or sets a value which indicates whether or not to automatically create and
2828 /// configure queues.
2929 /// </summary>
30+ /// <remarks>
31+ /// On initialisation if this property is <cc>true</cc> we will create and check all queues
32+ /// immediately, otherwise we delay the creation of the queue clients until they are first
33+ /// requested.
34+ /// </remarks>
3035 public bool CheckAndCreateQueues { get ; set ; }
3136
3237 public string ConnectionString { get ; set ; }
You can’t perform that action at this time.
0 commit comments