private void CreateIfNotExist() { if (!Exists()) { if (_localeQueueMode.In(LocaleQueueMode.DurableCreate, LocaleQueueMode.TemporaryMaster)) { using (var mutex = new Mutex(true, $@"Global\Grumpy.MessageQueue.{Name}")) { mutex.WaitOne(10000); if (!Exists()) { DisconnectInternal(); Create(); } mutex.ReleaseMutex(); } } else { throw new QueueMissingException(Name); } } }
/// <inheritdoc /> public LocaleQueue(ILogger logger, IMessageQueueManager messageQueueManager, IMessageQueueTransactionFactory messageQueueTransactionFactory, string name, bool privateQueue, LocaleQueueMode localeQueueMode, bool transactional, AccessMode accessMode) : base(logger, messageQueueManager, messageQueueTransactionFactory, name, privateQueue, localeQueueMode.In(LocaleQueueMode.Durable, LocaleQueueMode.DurableCreate), transactional, accessMode) { _localeQueueMode = localeQueueMode; switch (_localeQueueMode) { case LocaleQueueMode.TemporaryMaster: Create(); base.ConnectInternal(); break; case LocaleQueueMode.DurableCreate: CreateIfNotExist(); break; case LocaleQueueMode.Durable: break; case LocaleQueueMode.TemporarySlave: break; default: throw new ArgumentOutOfRangeException(); } }