NServiceBus icon indicating copy to clipboard operation
NServiceBus copied to clipboard

Queue creation fails for RabbitMQ when not run under debugger

Open JustinThirkell opened this issue 13 years ago • 4 comments

I'm pretty sure I know what's happening with this one but absolutely no idea why... I have an endpoint which refuses to create queues unless I run it under the debugger.

Using "NServiceBus (unstable) 4.0.0-unstable3060". (14th May). RabbitMQ transport. The endpoint has a single commandhandler which drains a queue and publishes events.

The logs output for Start-WithoutDebugging show this: http://imgur.com/KTWvpO6
Whereas if I run Start-Debugging the logs show this: http://imgur.com/rvvFKxP

What appears to be happening (took me ages to spot this) is that when it fails, the RabbitMQ.PersistentConnection is somehow disposed before it tries to connect - and silently fails. This is bad because as the bus starts up it all looks ok except the queue hasn't been created and so the threads that try to read from it eventually fall over and take down the process. I have run and re-run this process a lot and it (the problem) never happens while debugging - only without debugging.

Relevant code block is http://imgur.com/uaaW6FZ - I don't understand what's going on with the disposed check (why the PersistentConnection would be disposed when run without debugging but so far never disposed when run with debugging), nor why it doesn't throw an ObjectDisposedException. Obviously something is causing the PersistentConnection to be disposed, don't know what though.

I don't know if it's at all related or just coincidental but another process I have which subscribes to the published events never has this problem (in debug or non-debug mode) - queues are always created when the process is just subscribing to events.

JustinThirkell avatar May 17 '13 03:05 JustinThirkell

Are you using our host? The host only creates queues if u pass -install to it or you running with debugger attached

johnsimons avatar May 17 '13 04:05 johnsimons

yes, that's exactly it. thanks.

I reckon it would be really useful if NSB output a warning message when starting up the host with a profile that doesn't include running installers... or maybe if you want to keep warnings to a minimum, then output a warning message when the installers are automatically run for you - then it would be obvious when comparing the logs that something is different. The reason it took me so long to figure out something was wrong was because the logs looked exactly the same.

JustinThirkell avatar May 17 '13 05:05 JustinThirkell

and now that i re-read my original bug report - there's a lot of "debug|not-debug" in there. now i remember about hosts and profiles it's kind of obvious that it was debug (and therefore infrastructure-installs) -related. sigh i definitely think there could be some more pointing towards the pit of success here. :) thanks again though - you and andreas answered at the same time, nice to have a quick turnaround!

JustinThirkell avatar May 17 '13 05:05 JustinThirkell

I'll close this, glad it is sorted :) BTW, I agree with you, IMO having the pit of success at the begging (by creating queues automatically if debugging) is not really helpful because later on when it comes to deploying time, the dev hasn't actually learned how to do it for real!

johnsimons avatar May 17 '13 05:05 johnsimons