MSSQL Service Broker Does Not Work

It's time for a project I've not seen in awhile to get some love. It's .NET MVC running against SQL Server.

I fire it up. After some really annoying compiler reference issues (how does this happen on a project that has not been touched?), I get a dev version up and running.

I want to work on a copy of the database but I also want to leave the original up for reference as I move forward. So, I back up, make a new database and restore into it. I run my initialization script that, mainly, establishes a service broker. Edit the connection string to point at the new database, and, drum roll. . . . .

No love. The service broker is not configured properly.

This stuff worked just fine last time I used it and for years before that. I check a billion things. I recreate the database making sure I didn't screw anything up. I turn on the debugger and look at it from the program's viewpoint. Nothing does any good.

I am beat. After another round of dejected facebook or twitter or something, I am just staring at Management Studio. I, once again, look at the properties of the database. Goddam, Service Broker is turned on. I look at the original database again, Service Broker is turned on.

But I notice the GUID for the first time.

Bottom line, the Service Broker GUID was restored along with the rest of the database. For no particular reason (probably a guy who worked here years ago), I was setting ENABLE_BROKER.

A little google later and I learned about NEW_BROKER. Done. Works.

If you have a service broker that doesn't work, won't respond or otherwise gives you a big pain, check the database property/options and scroll down to service broker. If the GUID is the same as in another database, there's your problem.

OR, you could immediately try, ...

ALTER DATABASE [database name] SET NEW_BROKER WITH ROLLBACK IMMEDIATE;

And go to lunch.