问题
In the examples I can find of communicating between server instances using SQL Server Service Broker (here and here), route
s are created to the MSDB
database which is one of the system databases. For example
use msdb;
go
create route [sender]
with service_name = ‘sender’,
address = ‘local’;
go
Why would I not create the route in the database that has the rest of the Service Broker objects such as message types and services? Is this how a production environment should do it?
回答1:
Messages received from network are routed inside the SQL Server instance according to routing rules of msdb. This is by convention, the routing rules have to be declared somewhere and we picked msdb. Normally msdb contains the AutoCreatedLocal route which makes all services, in any database, addressable. One can remove this global route and add explicit routes for some services, which will make only those services addressable. I didn't see this done in practice, though. Most times the AutoCreatedLocal route is left in place an will handle all incoming traffic.
Note that msdb routes are used for forwarding scenarios where a machine accepts messages from one network and route them onto another one.
来源:https://stackoverflow.com/questions/38472867/is-routing-messages-to-the-msdb-sql-database-required-in-sql-service-broker