我已经在我的包中实现了一个发送邮件任务,它在成功或失败时发送邮件通知。发送邮件任务有时会由于以下错误而失败。
Task failed: Send Mail Task with Success
Error Code: -1073548540
ErrorMessage: An error occurred with the following error message: "Failure sending mail.
System.IO.IOException: Unable to read data from the transport connection:
An existing connection was forcibly closed by the remote host.
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host"我已经向网络管理员报告了这个问题,但是他们建议如下。
The errors you are receiving from Mailhub can happen occasionally when trying to open a connection.
The only way to resolve this issue is to force multiple retries. If you can, please try to code in ~3-4 retries in your app.我确信它可以通过脚本任务来完成。我不确定是否可以在使用“发送邮件”任务失败时实现多次尝试。
我已经实现了20多个包发送邮件的任务。我试着用最小的改动来实现这个方法。
我尝试了with SQL Server代理作业步骤配置,用户可以选择配置重试尝试和重试间隔,但是它在失败时运行整个包,这不适合我的方案。我必须只运行发送邮件任务,以防止它失败发送电子邮件多次尝试。
发布于 2020-01-03 15:42:39
您提到了C#选项:
下面是您要寻找的逻辑:
int retryCount = 0;
retry:
try
{
[Build and send your email]
}
catch
{
retryCount++;
if(retryCount<4) goto retry; //will try 4 times no matter what caused it to fall in to the catch
}发布于 2020-01-03 10:01:49
不要修改项目太多。
使用for容器创建一个新的包,您可以在其中控制重复次数。
创建一个int类型的变量。
添加包执行任务。
在正确执行的情况下,向中断for循环的变量分配一个值。
如果出现错误,您可以在数据库或任何您想要的地方注册它。
下图为ssis-2008,而ssis-2012则相同。

https://stackoverflow.com/questions/59576097
复制相似问题