简体   繁体   English

我可以使用 WCF 在 2 个 windows 服务之间进行通信(发送消息)吗?

[英]Can I use WCF for communicating (sending message) between 2 windows service?

Can I use WCF for communicating between 2 windows service?我可以使用 WCF 在 2 个 windows 服务之间进行通信吗? If yes, How?如果是,如何?

It depends on the type of message you want to transfer.这取决于您要传输的消息类型。 There is a lot of possible solutions:有很多可能的解决方案:

  • MSMQ messages MSMQ 消息
  • Duplex contracts双重合同
  • Named pipes命名管道

Basically you need to setup a WCF service on each windows service.基本上你需要在每个 windows 服务上设置一个 WCF 服务。 You can use the WCF 4.0 discovery features to dynamically find the each service.您可以使用 WCF 4.0 发现功能来动态查找每个服务。

Yes, It is possible.对的,这是可能的。 You can use ServiceHost class to host a WCF service in a windows service without dependency to IIS.您可以使用 ServiceHost class 在 windows 服务中托管 WCF 服务,而不依赖于 Z5DA5ACF461B5EFB7E266B68。

Sure;当然; you'd usually define a service contract (interface) which the two services will use to exchange messages;您通常会定义一个服务合同(接口),这两个服务将使用它来交换消息; then one of the windows services would host a WCF service (in this case, where the two services are in the same machine, you'd usually use a local-only binding, such as named pipes).那么 windows 服务之一将托管 WCF 服务(在这种情况下,两个服务位于同一台机器上,您通常会使用仅限本地的绑定,例如命名管道)。 Then the second win service can act as a client for the WCF service on the other windows services.然后第二个win服务可以作为WCF服务在其他windows服务上的客户端。 Is there any specific issue you're facing?你有什么具体的问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM