超时错误 - 通过 SQL Mail 发送邮件 - Service Broker 队列
这是我的第一个问题!因此,我希望我提供足够的信息:
我们正在尝试利用 SQL Mail Service Broker 发送大约 1000 封电子邮件。我们对此还比较陌生,但遇到了这个问题:
一些背景:
我们创建了一个配置文件、一个帐户和一个配置文件帐户条目,并启用了数据库邮件。然后我们用几封电子邮件进行了测试,一切正常。然后,我们创建了一个存储过程,我们将从项目中调用该存储过程,以使用 msdb.dbo.sp_send_dbmail 对所有电子邮件进行排队。效果很好,我们可以在 msdb.dbo.sysmail_mailitems 中看到所有邮件成功排队。然后,Service Broker 就会采取行动并开始处理电子邮件。
问题:
发送大约 90 个左右(绝不相同的数字)后,sql 事件日志中会多次报告错误
由于邮件原因,邮件无法发送给收件人 服务器故障。(使用帐户 42 发送邮件 (2011-09-19T17:20:09)。 异常消息:无法将邮件发送到邮件服务器。 (操作 已超时。)。使用帐户 42 发送邮件 (2011-09-19T17:21:59)。 异常消息:无法将邮件发送到邮件服务器。 (发送失败 邮件。)。 )
我参考了这个网站寻求帮助: http://www.sqlteam.com/article/how-to -troubleshoot-service-broker-problems
这让我有点困惑,我在代理运行时运行了查询分析器,一切看起来都很好。
我执行了以下命令:
select * from sys.dm_broker_queue_monitors
它显示了状态为 NOTIFIED 的代理队列。 这种“NOTIFIED”状态似乎意味着激活 sp 不起作用,但日志没有表明这一点,我检查了以下所有内容,但没有给我任何线索:
select * from sys.transmission_queue; select * from sys.conversation_endpoints; select * from sys.dm_broker_activated_tasks; select * from sys.dm_broker_connections;
如果我运行以下命令:
EXEC msdb.dbo.sysmail_stop_sp; EXEC msdb.dbo.sysmail_start_sp;
代理再次启动,同样的情况发生。
Windows 事件日志似乎显示了最有用的消息,但我不确定如何解决它:
Event Type: Error Event Source: DatabaseMail Event Category: None Event ID: 0 Date: 9/19/2011 Time: 5:18:44 PM User: N/A Computer: _____ Description: There was an error on the connection. Reason: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
并且如果我运行以下命令:“select * from dbo.sysmail_log;”我看到了我在这篇文章顶部显示的一长串超时错误。我还发现,当所有这些错误发生时,它会关闭代理服务(我认为它被称为消息中毒),因此我需要运行 sysmail_stop_sp 并开始让它再次运行。
感谢您的帮助,我希望我提供了足够的信息。
查尔斯
This is my first question! So I hope I provide enough information:
We are attempting to send around 1000 emails by taking advantage of the SQL Mail Service Broker. We are relatively new to this, but have hit a wall with this problem:
Some Background:
We created a Profile, an Account and a ProfileAccount entries, and enable database mail. We then tested with a few emails and all worked fine. We then created a store procedure that we would call from our project to QUEUE all the emails using msdb.dbo.sp_send_dbmail. This worked well, and we can see all the mail queued up successfully in msdb.dbo.sysmail_mailitems. The Service Broker then fires into action and starts processing the emails.
The Problem:
After sending roughly 90 or so (never the same number) an error is reported many times in the sql event logs
The mail could not be sent to the recipients because of the mail
server failure.(Sending Mail using Account 42 (2011-09-19T17:20:09).
Exception Message: Cannot send mails to mail server. (The operation
has timed out.). Sending Mail using Account 42 (2011-09-19T17:21:59).
Exception Message: Cannot send mails to mail server. (Failure sending
mail.). )
I refered to this website for help:
http://www.sqlteam.com/article/how-to-troubleshoot-service-broker-problems
Which made me a little confused, I have run Query Profiler while the Broker is running and all seems fine.
I executed this:
select * from sys.dm_broker_queue_monitors
which displayed the broker queue with a state of NOTIFIED.
This 'NOTIFIED' state seem to imply that the activation sp wasn't working, but the logs don't indicate this, and I checked all the following which didn't give me any clue:
select * from sys.transmission_queue; select * from sys.conversation_endpoints; select * from sys.dm_broker_activated_tasks; select * from sys.dm_broker_connections;
If I run the following commands:
EXEC msdb.dbo.sysmail_stop_sp; EXEC msdb.dbo.sysmail_start_sp;
the broker starts up again, and the same thing happens.
The windows event log seemed to show the most helpful message, but I'm unsure how to solve it:
Event Type: Error Event Source: DatabaseMail Event Category: None Event ID: 0 Date: 9/19/2011 Time: 5:18:44 PM User: N/A Computer: _____ Description: There was an error on the connection. Reason: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
And together with that the if I run this: "select * from dbo.sysmail_log;" I see long list of the timeout errors I showed at the top of this post. I have also discovered that when all these errors occur it closes down the Broker Service (Message Poisoning I think it's called) so therefore I need to run the sysmail_stop_sp and start to get it going again.
Thanks for your help, and I hope I provided enough information.
Charles
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到过类似的问题,但不幸的是从未得到答案。最后,我所能做的就是监视队列,当它崩溃时重新启动它。我使用以下存储过程来执行此操作。
我希望这对你有一些帮助。如果是这样,请记住将此标记为答案!
亲切的问候,
威廉
I have had a similar problem, but unfortunately never got an answer. In the end, all that I could do was to monitor the QUEUE and when it has crashed just restart it. I used the following stored procedure to do this.
I hope this is of some help to you. If so, please remember to mark this as the answer!
Kind regards,
Willem