简体   繁体   中英

Windows service design with WCF

Currently I'm working on a design for a Windows Service application to fetch reports from an Oracle database, aggregate them to a message and send it to an external WCF SOAP service. I would be grateful for some design suggestions concerning Windows services.

Should Windows Services use eg dedicated WAS/self-hosted WCF service (net.pipe/net.tcp) that provides data to achieve better separation / reusability?

So I would add a WCF service (net.pipe) that provides data (eg a GetReport method). The Windows Service application would call GetReport and call the remote SOAP service to forward the aggregated message. The remote service and its client code are likely to change. It might be adapted for different customer projects.

If I understand correctly, your windows service will periodically fetch some data from the database and upload that data to a remote web service.

This means that your windows service is a client in terms of WCF communication and you won't need to implement any WCF server code inside it.

All you'll have to do is to connect to the remove web service and upload the data, eg using a client proxy generated for this remove service.

I don't think that it is required to add another WCF service that provides the data instead of querying the database directly as long as you don't have the requirement that another application will use the same WCF service. Until then I wouldn't add the service for the following reasons:

  • Another WCF service increases the complexity of the deployment and makes it harder to install and configure.
  • The connection to the new WCF service is another point that can break .
  • If you handle lots of data, getting them from the database directly is much more efficient instead of transferring them over a service protocol. As I understand your question, you aggregate the data in the windows service not in the database. Therefore you'd have to move the aggregation code to the new service also.

As said before, this recommendation will change once you have another potential client to the new service. In order to prepare for that, you should of course choose a design in your windows service that separates concerns well and is a good starting point to move some components later.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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