需要有关CLR Trigger + WCF + Windows Service的建议 [英] Need suggestion about CLR Trigger+ WCF + Windows Service

查看:73
本文介绍了需要有关CLR Trigger + WCF + Windows Service的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试达成类似
的任务
步骤1:

任何新记录都会插入到我的数据库中,我使用clr触发器将新记录的详细信息(例如:文件名和位置)传递给WCF.到目前为止,我已经实现了.
现在正计划移至步骤2,例如:

在WCF中编写ftpwebrequest并从目标位置下载文件(我使用CLR触发器从数据库获取文件名和位置)

现在我很困惑,如果一次插入多个记录会发生什么情况

CLR触发器将如何处理?一旦信息传递到WCF,由于某种原因,FTP将失败,这将在这里发生.

我在想而不是将数据库信息传递回WCF,而是将其写入文本文件中,然后编写一些Windows服务来读取信息并通过FTP获取文件.一旦完成,请从文本文件中删除该信息. >
请指导我解决该问题的方法或其他解决方法.

在Advance中致谢

Hi All,

Am trying to acheive a task like

Step1:

Any new record get insert in to my DB,i use clr trigger to pass the new record details (eg: Filename and Location)to WCF.I acheived so far here.

Now am planning to move to step 2 like:

write a ftpwebrequest inside WCF and download the file from destination (the filename and location i use to get from DB using CLR Trigger)

Now i got confused here,whats going to happend if there are more than 1 record inserted at a time

How the CLR trigger going to handle ? Once the information passed to WCF,for some reason the FTP failed what''s going to happen here.

I was thinking rather than pass the DB info back to WCF,write it in a text file and then write some windows service to read the info and get the file thru FTP.once it done delete that info from the text file.

Please guide me which one is make sense or any other way to work around this issues.

Thanks in Advance

推荐答案

对WCF服务的每个CLR触发器调用都将在单独的线程上.因此,只要您的FTP请求代码是线程安全的,就不会有问题.

您到底想在这里使用Windows服务来实现什么?
如果要用Windows Service替换WCF服务,则不会有任何区别.

取而代之的是,看看是否有可能-
a)对于每个新记录,请查看是否存在主键,并将其与FileName和Location一起发送到服务
b)添加一个try catch块,并捕获通过FTP获取文件时出现的任何错误
c)如果可以从服务访问数据库行主键,则将其记录到任何方便的位置,甚至更新数据库.

更新数据库中的状态是一个好主意.
这样,您至少可以获取失败的行.
您要如何处理失败的案件是另一回事.
Each CLR trigger call to the WCF service will be on a separate thread. So as long as your FTP request code is thread safe there should not be a problem.

What exactly are you trying to achieve using a Windows Service here?
If you are replacing the WCF service with a Windows Service, it is not going to make any difference.

Instead of that, see if this is possible -
a) for every new record, see if there is a primary key and send it along with FileName and Location to the service
b) add a try catch block and trap any error in getting the file through FTP
c) log the DB row primary key with the exception to any convenient location or even update the database, if it is reachable from the service.

Updating the status in the database, is a good idea.
This way you will be able to at least get the failed rows.
How you want to handle the failed cases is another story.


这篇关于需要有关CLR Trigger + WCF + Windows Service的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆