在 SQL Server 2008 中启用 Service Broker
我正在集成 SqlCacheDependency 以在我的 LinqToSQL 数据上下文中使用。
我正在使用此处找到的 Linq 查询的扩展类 - http://code.msdn.microsoft.com/linqtosqlcache
我已经连接了代码,当我打开页面时,我收到此异常 -
“当前数据库的 SQL Server Service Broker 未启用,因此不支持查询通知。请启用 Service Broker如果您想使用通知,请访问此数据库。”
它来自 global.asax 中的此事件,
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
//In Application Start Event
System.Data.SqlClient.SqlDependency.Start(new dataContextDataContext().Connection.ConnectionString);
}
我的问题是...
如何在 SQL Server 2008 数据库中启用 Service Broker?我尝试运行此查询.. ALTER DATABASE tablename SET ENABLE_BROKER 但它永远不会结束并永远运行,我必须手动停止它。
一旦我在 SQL Server 2008 中设置了此设置,它是否会过滤到我的 DataContext,或者我是否还需要在那里配置某些内容?
的帮助
感谢您
I am integrating SqlCacheDependency to use in my LinqToSQL datacontext.
I am using an extension class for Linq querys found here - http://code.msdn.microsoft.com/linqtosqlcache
I have wired up the code and when I open the page I get this exception -
"The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications."
its coming from this event in the global.asax
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
//In Application Start Event
System.Data.SqlClient.SqlDependency.Start(new dataContextDataContext().Connection.ConnectionString);
}
my question is...
how do i enable Service Broker in my SQL server 2008 database? I have tried to run this query.. ALTER DATABASE tablename SET ENABLE_BROKER but it never ends and runs for ever, I have to manually stop it.
once I have this set in SQL server 2008, will it filter down to my DataContext, or do I need to configure something there too ?
thanks for any help
Truegilly
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果其他人正在寻找此问题的解决方案,以下命令对我来说非常有用。它释放与数据库的所有其他连接,而不是等待。
In case anyone else is looking for a solution to this problem, the following command worked great for me. It releases all other connections to the database instead of waiting.
在 Sql Server 2012 中,您可以转到“属性”->“属性”。选项->服务代理
In Sql Server 2012 you can go to
Properties-> Options -> Service Broker
好的,如果您的备份被禁用或您需要恢复备份(这似乎会禁用它),请执行以下操作。
只要运行这个脚本,它就会杀死数据库正在使用的所有进程(为什么你不能在 2008 年手动杀死进程,不像 2005 年),然后设置代理
ok here is how to do this if yours is disabled or you need to restore a backup, which seems to disable it.
just run this script, it will kill all the process's that a database is using (why you carnt in 2008 manually kill process's unlike 2005 is beyond me) and then set the broker
必须删除与数据库的所有连接,并且具有用于启用代理服务的权限的用户帐户。
以下内容是理想的(替换
databasename
):我还建议创建一个具有适当权限的新角色和用户帐户(替换数据库登录):
All connections to the DB must be be dropped and user account with permissions used to enable the broker service.
The following would be ideal (replace
databasename
):Also I suggest creating a new role and user account with the proper permissions (replace database login):
我们可以通过 ALTER DATABASE 语句以及数据库属性 > 来启用 Broker 服务。选项>服务经纪人>代理启用:对/错。
但在启用代理时出现问题:进程正在与特定数据库一起运行,我们必须杀死这些进程,只有在此之后我们才能启用代理服务。 @JGilmartin 的回答将完美地工作,但请确保它会杀死数据库的所有正在进行的进程,在生产中使用此脚本之前,请检查流量或进程的严重性。
We can enable Broker services by ALTER DATABASE statement and also from Database properties > Options > Service Broker > Broker Enable: True/False.
But issue here while enabling the broker: processes are running with the specific database we have to kill those and only after that we can enable broker service. answered by @JGilmartin will perfectly work, but make sure it'll kill all ongoing processes of your database, before using this script on production kindly check traffic or severity of process.
Service Broker 输出错误。图片1
要修复此问题,请使用 SSMS 启用 Service Broker,图 2
设置为 true 后,Service Broker 错误现在应该消失了,请参阅我的图 3
Error Outputted by Service Broker. Image 1
To Fix, enable Service broker using SSMS, Image 2
After Setting to true Service Broker error should gone now, see my Image 3
如果代理已启用,请尝试以下操作:
If the broker is already enabled try this: