protected override ConsoleExecuteResult ValidateQueue(string queueName) { if (!Queues.ContainsKey(queueName)) { return(new ConsoleExecuteResult($"{queueName} was not found. Call CreateQueue to create the queue first")); } return(null); }
/// <summary> /// Create new observer /// </summary> public override ITransportEndpointObserver CreateObserver(TransportEndpointAddress transportEndpointAddress) { if (!Queues.ContainsKey(transportEndpointAddress.GetFriendlyName())) { throw new Exception($"There is no queue with name {transportEndpointAddress.GetFriendlyName()}."); } return((ITransportEndpointObserver)Queues[transportEndpointAddress.GetFriendlyName()]); }
private QueueObject GetQueueInternal(string queueName) { var returnValue = default(QueueObject); if (Queues.ContainsKey(queueName)) { returnValue = Queues[queueName]; } return(returnValue); }
public CloudQueue GetQueue(string queueName) { try { if (!Queues.ContainsKey(queueName)) { var queue = Client.GetQueueReference(queueName); queue.CreateIfNotExists(); } return(Queues[queueName]); } finally { Semaphore.Release(); } }
public async Task <CloudQueue> GetQueueAsync(string queueName) { await Semaphore.WaitAsync(); try { if (!Queues.ContainsKey(queueName)) { var queue = Client.GetQueueReference(queueName); await queue.CreateIfNotExistsAsync(); } return(Queues[queueName]); } finally { Semaphore.Release(); } }
public FMSSettings(IConfiguration config) { var fmsSection = config.GetSection("FMS"); DataDirectory = fmsSection.GetValue <string>("DataDirectory", null); if (string.IsNullOrEmpty(DataDirectory)) { DataDirectory = DefaultDataDirectory(); } if (fmsSection.GetValue <bool>("AutomaticSerials", false)) { SerialType = SerialType.AssignOneSerialPerMaterial; } SerialLength = fmsSection.GetValue <int>("SerialLength", 10); StartingSerial = fmsSection.GetValue <string>("StartingSerial", null); RequireScanAtWash = fmsSection.GetValue <bool>("RequireScanAtWash", false); RequireWorkorderBeforeAllowWashComplete = fmsSection.GetValue <bool>("RequireWorkorderBeforeAllowWashComplete", false); QuarantineQueue = fmsSection.GetValue <string>("QuarantineQueue", null); AdditionalLogServers = fmsSection.GetValue <string>("AdditionalServersForLogs", "") .Split(',') .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => { var uri = new UriBuilder(x); if (uri.Scheme == "") { uri.Scheme = "http"; } if (uri.Port == 80 && x.IndexOf(':') < 0) { uri.Port = 5000; } var uriS = uri.Uri.ToString(); // remove trailing slash return(uriS.Substring(0, uriS.Length - 1)); }) .ToList(); InstructionFilePath = fmsSection.GetValue <string>("InstructionFilePath"); foreach (var q in config.GetSection("QUEUE").AsEnumerable()) { var key = q.Key.Substring(q.Key.IndexOf(':') + 1); if (q.Key.IndexOf(':') >= 0 && !string.IsNullOrEmpty(key) && int.TryParse(q.Value, out int count)) { Queues[key] = new MachineWatchInterface.QueueSize() { MaxSizeBeforeStopUnloading = count > 0 ? (int?)count : null }; } } foreach (var q in config.GetSection("EXTERNAL_QUEUE").AsEnumerable()) { var key = q.Key.Substring(q.Key.IndexOf(':') + 1); if (q.Key.IndexOf(':') >= 0 && !string.IsNullOrEmpty(key)) { ExternalQueues[key] = q.Value; } } if (!string.IsNullOrEmpty(QuarantineQueue) && !Queues.ContainsKey(QuarantineQueue) && !ExternalQueues.ContainsKey(QuarantineQueue)) { Serilog.Log.Error("QuarantineQueue {queue} is not configured as a queue or external queue", QuarantineQueue); } }