Thank you for sending us the complete code.
The main issue was that args.Message.ApplicationName.ToString();
raised NullReferenceException
on a background task, which stopped execution of the foreach (var args in messageQueue.GetConsumingEnumerable())
loop.
Please note that string properties of the args.Message can be null
if the client did not send their value.
I also suggest to put body of the message processing foreach
loop into try-catch
block and handle errors appropriately.