SSIS 跨进程通信有哪些选项?
我想存储一个递增和递减的整数变量(用于限制对外部 API 的并发请求的计数信号量)。这很容易,但我需要一种方法从并行 SQL 代理作业中运行的 SSIS 包中读取/写入此变量。现在可以有 0 到 5 个 SQL 代理作业实例,因此 SSIS 包同时运行。
读取和写入此变量的选项有哪些?将使用此变量的代码被编写为 .NET 中的自定义 SSIS 任务。
该值是否完全正确并不特别重要,只要它大致接近我在公差范围内即可。精确就很好,但不是必需的。
我可以访问整个文件系统、注册表、数据库、服务器和 SSIS 代理,但我想通过 15-30 个线程经常检查此变量,这在历史上曾导致使用文件系统方法出现问题(我可能做错了),并且 IMO 太密集而无法存储在数据库中。如果我错了请纠正我。存储在注册表中可防止跨服务器场访问该变量。
如果有人可以帮忙,我很乐意成为您的契约仆人。
I would like to store an integer variable that gets incremented and decremented (a counting semaphore for limiting concurrent requests to an external API). This would be easy, except I need a way to read/write this variable from an SSIS package that is run in parallel SQL Agent jobs. Right now there can be 0 to 5 instances of the SQL Agent job, and therefore the SSIS package, running at once.
What are my options for reading and writing this variable? The code that will be using this variable is written as a custom SSIS task in .NET.
It is not particularly important that the value is exactly right, as long as it's generally close I'm within a tolerance range. Exact would be great, but not required.
I have access to the file system, registry, database, server, and the SSIS agent as a whole, but I'd like to check this variable very often by 15-30 threads, which has historically caused issues using a file system method (I'm probably doing it wrong), and is IMO too intensive to store in the database. Correct me if I'm wrong. Storing in the registry prevents the variable from being accessible across a server farm.
If there's anyone out there that can help, I will gladly be your indentured servant.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它用作计数信号量,为什么不实际使用Windows信号量对象呢?
System.Threading.Semaphore 是它的 .NET 版本,如果您在构造函数中指定信号量名称 - Win32 对象将在使用该名称的所有进程之间共享。
If it is used as counting semaphore, why not actually use Windows semaphore object?
System.Threading.Semaphore is .NET version of it, and if you specify the semaphore name in constructor - the Win32 object will be shared between all the processes that use this name.
不确定我是否理解这个问题 - 您表示您可以访问数据库、文件系统、注册表等。您是说您不想/不能使用这些方法吗?您是否希望保留该值,以便在计算机停止运行时可以恢复?
如果不需要持久化,您可以通过 RPC(包括 COM 或 Web 服务)在内存中持久化。无论解决方案是什么,它似乎都需要是全局的并且对所有正在运行的实例可见。
该变量元数据是用作控制和协调流程的信号量,还是变量域数据?
Not sure I understand the question - you indicated you have access to a Database, file system, registry, etc. Are you saying you don't want to / can't use these methods? Are you looking to persist the value so in the event the computer halts you can recover?
If persistance is not required, you could persist in memory via an RPC, including COM or web services. Whatever the solution, it seems it needs to be global and visible to all running instances.
Is this variable metadata used as a semaphore to control and coordinate the processes, or is this variable domain data?