public ServiceBusManager(ServiceBusQueueOptions options) { if (options == null) throw new ArgumentNullException("options"); _options = options; _clients = new Dictionary<string, QueueClient>(); _namespaceManager = NamespaceManager.CreateFromConnectionString(options.ConnectionString); CreateQueuesIfNotExists(_namespaceManager, options); }
public ServiceBusQueueJobQueueProvider(ServiceBusQueueOptions options) { if (options == null) throw new ArgumentNullException("options"); options.Validate(); var manager = new ServiceBusManager(options); _jobQueue = new ServiceBusQueueJobQueue(manager); _monitoringApi = new ServiceBusQueueMonitoringApi(manager, options.Queues); }
public static SqlServerStorage UseServiceBusQueues( this SqlServerStorage storage, ServiceBusQueueOptions options) { if (storage == null) throw new ArgumentNullException("storage"); if (options == null) throw new ArgumentNullException("options"); var provider = new ServiceBusQueueJobQueueProvider(options); storage.QueueProviders.Add(provider, options.Queues); return storage; }
public ServiceBusQueueJobQueueProvider(ServiceBusQueueOptions options) { if (options == null) { throw new ArgumentNullException("options"); } options.Validate(); var manager = new ServiceBusManager(options); _jobQueue = new ServiceBusQueueJobQueue(manager); _monitoringApi = new ServiceBusQueueMonitoringApi(manager, options.Queues); }
public ServiceBusManager(ServiceBusQueueOptions options) { if (options == null) { throw new ArgumentNullException("options"); } _options = options; _clients = new Dictionary <string, QueueClient>(); _namespaceManager = NamespaceManager.CreateFromConnectionString(options.ConnectionString); CreateQueuesIfNotExists(_namespaceManager, options); }
public ServiceBusQueueJobQueue(ServiceBusManager manager, ServiceBusQueueOptions options) { if (manager == null) { throw new ArgumentNullException("manager"); } if (options == null) { throw new ArgumentNullException("options"); } _manager = manager; _options = options; }
private static void CreateQueuesIfNotExists(NamespaceManager namespaceManager, ServiceBusQueueOptions options) { foreach (var queue in options.Queues) { var prefixed = options.GetQueueName(queue); if (!namespaceManager.QueueExists(prefixed)) { var description = new QueueDescription(prefixed); if (options.Configure != null) { options.Configure(description); } namespaceManager.CreateQueue(description); } } }
public ServiceBusQueueJobQueueProvider(ServiceBusQueueOptions options) { if (options == null) { throw new ArgumentNullException("options"); } options.Validate(); Logger.Info("Using the following options for Azure service bus:"); Logger.InfoFormat(" Check and create queues: {0}", options.CheckAndCreateQueues); Logger.InfoFormat(" Queue prefix: {0}", options.QueuePrefix); Logger.InfoFormat(" Queues: [{0}]", string.Join(", ", options.Queues)); var manager = new ServiceBusManager(options); _jobQueue = new ServiceBusQueueJobQueue(manager, options); _monitoringApi = new ServiceBusQueueMonitoringApi(manager, options.Queues); }
public static SqlServerStorage UseServiceBusQueues( this SqlServerStorage storage, ServiceBusQueueOptions options) { if (storage == null) { throw new ArgumentNullException("storage"); } if (options == null) { throw new ArgumentNullException("options"); } var provider = new ServiceBusQueueJobQueueProvider(options); storage.QueueProviders.Add(provider, options.Queues); return(storage); }
public ServiceBusManager(ServiceBusQueueOptions options) { if (options == null) { throw new ArgumentNullException("options"); } _options = options; _clients = new Dictionary <string, QueueClient>(options.Queues.Length); _namespaceManager = NamespaceManager.CreateFromConnectionString(options.ConnectionString); _messagingFactory = MessagingFactory.CreateFromConnectionString(options.ConnectionString); // If we have this option set to true then we will create all clients up-front, otherwise // the creation will be delayed until the first client is retrieved if (options.CheckAndCreateQueues) { CreateQueueClients(); } }
private static void CreateQueueIfNotExists(string prefixedQueue, NamespaceManager namespaceManager, ServiceBusQueueOptions options) { if (options.CheckAndCreateQueues == false) { Logger.InfoFormat("Not checking for the existence of the queue {0}", prefixedQueue); return; } try { Logger.InfoFormat("Checking if queue {0} exists", prefixedQueue); if (namespaceManager.QueueExists(prefixedQueue)) { return; } Logger.InfoFormat("Creating new queue {0}", prefixedQueue); var description = new QueueDescription(prefixedQueue); if (options.RequiresDuplicateDetection != null) { description.RequiresDuplicateDetection = options.RequiresDuplicateDetection.Value; } if (options.Configure != null) { options.Configure(description); } namespaceManager.CreateQueue(description); } catch (UnauthorizedAccessException ex) { var errorMessage = string.Format( "Queue '{0}' could not be checked / created, likely due to missing the 'Manage' permission. " + "You must either grant the 'Manage' permission, or set ServiceBusQueueOptions.CheckAndCreateQueues to false", prefixedQueue); throw new UnauthorizedAccessException(errorMessage, ex); } }