public IExchangeSpecifier DeclareQueue(string queueName, params string[] boundRoutes) { var qPath = _parent.GetQueuePath(_exchangeName, queueName); var qMtx = FDMessageBus.GetQueueMutex(_exchangeName, queueName); var exPath = _parent.GetExchangePath(_exchangeName); var exMtx = FDMessageBus.GetExchangeMutex(_exchangeName); using (exMtx) using (qMtx) { if (exMtx.Wait(TimeSpan.FromSeconds(30)) && qMtx.Wait(TimeSpan.FromSeconds(30))) { var di = new DirectoryInfo(qPath); if (di.Exists) { return(this); } di.Create(); var fi = new FileInfo(Path.Combine(qPath, "routes.json")); using (var sw = fi.CreateText()) { var q = new MessageQueueDeclaration { Name = queueName }; q.Bindings.AddRange(boundRoutes); var text = JsonConvert.SerializeObject(q); sw.Write(text); sw.Flush(); sw.Close(); } } } return(this); }