问题
After db restoring on other server the Service Broker is stopped. The restored db has a Trustworthy Off and now I set it to On to run Broker again. I understand that it is bad practice. Especially after reading articles by solomon-rutzky. I have made as Solomon advised for SQLCLR UNSAFE functions without setting database to TRUSTWORTHY ON. It works fine!
How to restore Broker working in case TRUSTWORTHY OFF?
回答1:
Trustworthy isn't required to run Service Broker. There is, however, an option that you can pass to the RESTORE
statement that is probably what you need. Quoting the docs:
ENABLE_BROKER
Specifies that Service Broker message delivery is enabled at the end of the restore so that messages can be sent immediately. By default Service Broker message delivery is disabled during a restore. The database retains the existing Service Broker identifier.
If you didn't do this, there is still hope! Post-restore, you can issue an alter databse [yourDB] set enable_broker;
. Note, this requires exclusive database access, so you might also need to add with rollback immediate
or similar to the alter database
statement.
来源:https://stackoverflow.com/questions/65681589/how-to-recover-service-broker-after-restoring-database