开发者

How to notify a Windows .net service from PHP on Linux?

I'm writing a service i开发者_JAVA技巧n 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?


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.


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜