How to recover Service Broker after restoring database?

断了今生、忘了曾经 提交于 2021-01-25 01:43:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!