diff --git a/src/ServiceStack.Redis/Messaging/RedisMqServer.cs b/src/ServiceStack.Redis/Messaging/RedisMqServer.cs index dcade039..8684e594 100644 --- a/src/ServiceStack.Redis/Messaging/RedisMqServer.cs +++ b/src/ServiceStack.Redis/Messaging/RedisMqServer.cs @@ -237,19 +237,30 @@ public void Start() SleepBackOffMultiplier(Interlocked.CompareExchange(ref noOfContinuousErrors, 0, 0)); - KillBgThreadIfExists(); + StartWorkerThreads(); - bgThread = new Thread(RunLoop) { - IsBackground = true, - Name = "Redis MQ Server " + Interlocked.Increment(ref bgThreadCount) - }; - bgThread.Start(); - Log.Debug("Started Background Thread: " + bgThread.Name); + //Don't kill us if we're the thread that's retrying to Start() after a failure. + if (bgThread != Thread.CurrentThread) + { + KillBgThreadIfExists(); - StartWorkerThreads(); + bgThread = new Thread(RunLoop) + { + IsBackground = true, + Name = "Redis MQ Server " + Interlocked.Increment(ref bgThreadCount) + }; + bgThread.Start(); + Log.Debug("Started Background Thread: " + bgThread.Name); + } + else + { + Log.Debug("Retrying RunLoop() on Thread: " + bgThread.Name); + RunLoop(); + } } catch (Exception ex) { + ex.Message.Print(); if (this.ErrorHandler != null) this.ErrorHandler(ex); } }