More on SQL Server Service Broker
2011-01-30 11:28
239 查看
In earlier posts I already blogged about creating some simple queuing solutions with SQL Server Service Broker. Last week I spend some time actually implementing my research in a customer project and of course ran into two 'interesting' issues.
It is possible for the Service Broker to somehow die on you, whilst appearing to be up and running and with RETENTION=ON sent message appear to be in the queue.
When using the SQL Profiler it becomes clear that messages don't get processed because the Service Broker is not enabled.
You can use the following statement to enable Service Broker:
alter database PFA_DATA set ENABLE_BROKER
I had to do it on two machines and on of them gave me the following error:
Msg 9772, Level 16, State 1, Line 2
The Service Broker in database "PFA_DATA" cannot be enabled because there is already an enabled Service Broker with the same ID.
Msg 5069, Level 16, State 1, Line 2
ALTER DATABASE statement failed.
So instead I used:
alter database PFA_DATA set NEW_BROKER
After this the Service Broker was up and running and message started getting delivered.
If the query takes extremely long to complete restart SQL Server and try again.
One potential cause for this is when you restore a database.
In my earlier post I just blatantly used WITH CLEANUP to avoid getting EndDialog messages.
The documentation however states:
WITH CLEANUP
Remove all messages and catalog view entries for this side of the conversation without notifying the other side of the conversation. Microsoft SQL Server drops the conversation endpoint, all messages for the conversation in the transmission queue, and all messages for the conversation in the service queue. Use this option to remove conversations which cannot complete normally. For example, if the remote service has been permanently removed, you use WITH CLEANUP to remove conversations to that service.
So use this sparingly.
I've discovered a much cleaner way to handle it.
When sending a message you can use "END CONVERSATION @dialog" to specify that as far as the sender is concerned the dialog is over. In other words: a fire and forget message.
When the receiving side of the conversation receives the messages and performs its "END CONVERSATION" statement, Service Broker will detect that no acknowledgement (EndDialog) needs to be send.
It is possible for the Service Broker to somehow die on you, whilst appearing to be up and running and with RETENTION=ON sent message appear to be in the queue.
When using the SQL Profiler it becomes clear that messages don't get processed because the Service Broker is not enabled.
You can use the following statement to enable Service Broker:
alter database PFA_DATA set ENABLE_BROKER
I had to do it on two machines and on of them gave me the following error:
Msg 9772, Level 16, State 1, Line 2
The Service Broker in database "PFA_DATA" cannot be enabled because there is already an enabled Service Broker with the same ID.
Msg 5069, Level 16, State 1, Line 2
ALTER DATABASE statement failed.
So instead I used:
alter database PFA_DATA set NEW_BROKER
After this the Service Broker was up and running and message started getting delivered.
If the query takes extremely long to complete restart SQL Server and try again.
One potential cause for this is when you restore a database.
In my earlier post I just blatantly used WITH CLEANUP to avoid getting EndDialog messages.
The documentation however states:
WITH CLEANUP
Remove all messages and catalog view entries for this side of the conversation without notifying the other side of the conversation. Microsoft SQL Server drops the conversation endpoint, all messages for the conversation in the transmission queue, and all messages for the conversation in the service queue. Use this option to remove conversations which cannot complete normally. For example, if the remote service has been permanently removed, you use WITH CLEANUP to remove conversations to that service.
So use this sparingly.
I've discovered a much cleaner way to handle it.
When sending a message you can use "END CONVERSATION @dialog" to specify that as far as the sender is concerned the dialog is over. In other words: a fire and forget message.
When the receiving side of the conversation receives the messages and performs its "END CONVERSATION" statement, Service Broker will detect that no acknowledgement (EndDialog) needs to be send.
相关文章推荐
- SQL Server Service Broker
- 未启用当前数据库的 SQL Server Service Broker,因此查询通知不受支持。如果希望使用通知,请为此数据库启用 Service Broker
- SqlServer service broker 分布式系统(赵松涛)深入浅出 2005 数据库编程
- 配置SQL Server服务代理来发送存储过程数据 SQL Server Service Broker - z
- Sql server Service Broker 简介
- 未启用当前数据库的 SQL Server Service Broker
- 微软公司的两大主流的通讯技术之一消息队列:MessageQueue(另一个是SQL Server Service Broker)
- 未启用当前数据库的 SQL Server Service Broker
- SqlServer service broker 分布式系统(赵松桃)跳水 2005 数据库编程
- 未启用当前数据库的 SQL Server Service Broker,因此查询通知不受支持。如果希望使用通知,请为此数据库启用 Service Broker
- How to Enable/Disable SQL Server Service Broker in script
- SQL Server Service Broker 简单例子 (转)
- SQL Server Service Broker – 消息队列
- An Introduction to SQL Server Service Broker [WORD DOCUMENT]
- 启动数据库SQL Server Service Broker
- 未启用当前数据库的 SQL Server Service Broker,因此查询通知不受支持。
- Microsoft SQL Server 2005 的 XML 最佳实施策略--SQL Server Service Broker使用
- 未启用当前数据库的 SQL Server Service Broker,因此查询通知不受支持。如果希望使用通知,请为此数据库启用 Service Broker
- 未启用当前数据库的 SQL Server Service Broker,因此查询通知不受支持。如果希望使用通知,请为此数据库启用 Service Broker
- SQL Server Service Broker