多次安装相同的服务...... [英] Having the same service installed multiple times...

查看:65
本文介绍了多次安装相同的服务......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个关于Windows服务的问题。

我创建了一个WCF服务,作为Windows服务托管,与客户端应用程序通信。一切都很好。

现在我想在不同的服务器上再次安装相同的服务。客户端应与两种服务进行通信。因此它应该打开,订阅,接收回调并向两个服务器上的两个服务(实际上是相同的服务)发送请求。

这甚至可能吗?或者只有打开两个客户端应用程序(每个服务器一个)才有可能?

我尝试使用谷歌搜索,但找不到任何东西(或者我不知道该找什么)。 br />
谢谢。

Hi all,
I have a question concerning Windows Services.
I created a WCF service, hosted as a Windows Service, that communicates with a client application. All works pretty well.
Now I want to install the same service again on a different server. The client should communicate with both services. So it should open, subscribe, receive callbacks and send requests to both services (that are actually the same service) on both servers.
Is this even possible? Or is it only possible when having two client applications open (one for each server)?
I tried Googling, but couldn't find anything (or I'm not sure what to look for).
Thanks.

推荐答案

是的,很有可能。实际上它们不是相同的服务。它们是在不同机器上运行的不同服务,具有相同的接口和数据类型(服务合同+数据合同)。顾名思义,服务是一个进程,用于监听其他进程(本地或远程,根据配置进行更改)以执行某些操作。因此,如果配置(服务配置,防火墙配置等)允许,您可以连接它们以获得服务,而不受上下文中的任何限制。两个不同的服务实例可能提供相同的数据(如果您请求获取某些数据)。这取决于你的设计。例如,它们可能共享相同的数据源(数据库),因此您可以获得相同服务方法调用的相同数据。如果他们的基础数据源不同,那么即使您调用相同的服务方法,也会从这些实例获得不同的数据。



yes, it is quite possible. actually they are NOT the same services. they are different services running on different machines, having the same interface and data types (service contract+data contract). service, as the name implies, a process listening for other processes (local or remote, changes according to configuration) to do something. therefore, if the configuration (service config, firewall config, etc) allows, you can connect them to get a service without any limitation in the context. two different service instances may provide the same data (if you request is to get some data), or not. it depends on your design. for example, they may share the same data source (database), therefore you get the same data for the same service method call. if their underlying data sources are different, you get different data from those instances even if you call the same service method, naturally.

Machine1.AServiceClient _clientMachine1 = new Machine1.AServiceClient();
Machine2.AServiceClient _clientMachine2 = new Machine2.AServiceClient();

Machine1.Data _data1 = _clientMachine1.GetData(); 
Machine2.Data _data2 = _clientMachine2.GetData();





在此示例中,_data1和_data2可能具有相同的数据,但他们的类型是不同的。第一个在Machine1命名空间下,另一个在Machine2命名空间下。



它不一定是这样的。您可以使用具有不同连接配置的相同客户端代码:





In this example, _data1 and _data2 may have the same data, but their types are different. the first one is under Machine1 namespace, and the other is under Machine2 namespace.

It doesn't have to be in this way. you can use the same client code with different connection configuration:

AServiceClient _clientMachine1 = new AServiceClient(config1); // for machine1
AServiceClient _clientMachine2 = new AServiceClient(config2); // for machine1

Data _data1 = _clientMachine1.GetData();
Data _data2 = _clientMachine2.GetData();





在这种情况下,_data1和_data2具有相同的类型,但它们是因为它们不同而仍然是不同的实例:)



实际上,你问题的客户端部分没有多大意义。因为服务是某种东西而服务客户是另一回事。您甚至可以在同一代码中为同一服务创建多个服务客户端。例如:



In this case, _data1 and _data2 have the same type but they are still different instances since they are different :)

actually, the client part of your question doesn't make much sense. because service is something and service-client is another thing. you can even create multiple service clients for the same service in the same code. such as:

AServiceClient _aclient1 = new AServiceClient(); 
AServiceClient _aclient2 = new AServiceClient(); 

_aclient1.DoSomething();
_aclient2.DoSomething();







我认为我的解决方案并不多感。因为,每个例子都是一切皆有可能:)




I think my solution doesn't make much sense. because, every example goes to 'everything is possible' :)


这篇关于多次安装相同的服务......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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