如何在 Linux 上从 PHP 通知 Windows .net 服务?

发布于 2024-09-05 15:11:16 字数 237 浏览 3 评论 0原文

我正在 Windows 上用 C# 编写一个服务,该服务应该由在 Linux 上运行的 PHP 驱动的 Web 前端触发。

两个进程共享相同的 SQL Server 2005 数据库。

atm 没有可用的消息传递中间件。

PHP 进程在 SQL Server 表中插入一行。 Windows 进程应该读取此条目并对其进行处理。

我没有 PHP 经验,那么您建议如何通知 Windows 进程?

I'm writing a service in C# on Windows which should be triggert by an PHP driven web frontend, which runs on Linux.

Both processes share the same SQL Server 2005 database.

There is no messaging middleware available atm.

The PHP process inserts an row in a SQL Server table. The Windows process should read this entry and process it.

I have no experience in PHP, so what would you suggest to notify the Windows process?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

柳絮泡泡 2024-09-12 15:11:16

我看到至少有两种方法可以完成该任务:

  1. 托管进程中的WCF服务 在 Windows 服务中和 从 PHP 调用它
  2. 从 PHP 在数据库中写入事件并使用 SqlDependency 订阅它们。

I see at least 2 ways to accomplish that task:

  1. Host in process WCF service in windows service and call it from PHP.
  2. Write events in the database from PHP and subscribe on them using SqlDependency.
谜泪 2024-09-12 15:11:16

查看 .Net 中的 SqlDependency。它允许您在 SQL 服务器上设置触发器。 MSDN 中有一个示例应用程序。

Check out SqlDependency in .Net. It allows you to set a trigger on the SQL server. There's a sample app at MSDN.

我们只是彼此的过ke 2024-09-12 15:11:16

让服务定期轮询 PHP 进程写入的数据库表。我做了类似的事情,表中有一列一开始为空,然后在处理该行后由 Windows 服务设置。该服务仅要求该字段中包含空值的第一行,执行该操作,然后更新该字段,然后重复。这样,如果系统或应用程序崩溃,那么在重新启动时,它会继续处理未处理的行。请记住将事务中的读取和写入括起来。

Have the service periodically poll the database table that the PHP process writes to. I do something similar and have a column in the table that is null to begin with, and then is set by the Windows service once the row is processed. The service merely asks for the first row that contains a null in this field, does it's thing, then updates the field, and then repeats. This way if the system or app crashes then when restarted it continues with that unprocessed row. Remember to bracket your reads and writes in transactions.

瀟灑尐姊 2024-09-12 15:11:16

我在这里回答我的问题,因为最终我们通过普通的旧套接字通知应用程序。

所以我的问题的有效答案是使用套接字。

I'm answering my question here, because in the end we notified the app via plain old sockets.

So a valid answer to my question is use sockets.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文