Saturday, May 26, 2012

WCF Service Vs Windows Service


This article is all about understanding WCF and Windows service. We will first try to understand what it is at high level and then dig in more.

WCF Service

WCF is meant for designing and deploying distributed applications and it’s a framework for building service-oriented applications.

What is SOA?

A service-oriented architecture is a collection of services. These services communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating each other to do some activity.

SOA is a buzz word also it is a misconception that when it comes to SOA, we have to create and consume WCF services.Some architects mistakenly assumes and considers WCF as default. However in theory point of view it doesn’t really matter how it’s being implemented. WCF just provides a means for developing distributed services.

We all started working with Web services before WCF came into picture. Web services by itself is service oriented implementation. Guys we already we aware of what are SOA.

Simply stating for SOA, the most basic components would be a service user and a service provider that’s all. As I already mentioned about WCF, its Microsoft’s implementation of service oriented architecture.

What is a Service?

In simple words, a service is the work performed by one that serves or helps.

A service is a reusable component that can be used as a building block to form larger, more complex business-application functionality.

Services are independent. They don’t know or really care whether the service is:
– Running on Windows, J2EE or a Mainframe
– Written in assembler, C, Java, or COBOL.
– Being served by a CRM system, a DDA system, or a database

Don’t think service as just one big massive thing. The services can be broken into compound and granular services.

Why do we need an SOA?

The systems that we build and use today are much complex ones. That doesn’t mean the older systems are not much complex. From my own personal experience, When I was working for Healthcare clearing house , there were products which were built with technology like Foxpro , VB, .NET components (these are legacy systems for now that’s a different story) which are still running since from nearly 20 yrs.

The Object Oriented (OO) solved the problem for medium sized systems or applications. The component orientation solved the problem that a simple objected oriented could not do in a medium sized products or applications. With large systems, neither of this could solve the problem.


When is SOA good and Bad?

Good when you are building a large system or systems of systems or planning for distributed systems then it’s good to go.

It’s bad when there are no distributed systems. It may not be feasible for small or medium sized systems.

Windows Service

Windows service is generally used when an application needs to run continuously in the background without any human intervention. The main functions of a windows service is to run in the background.

We can set the windows service to start automatically when the machine boots and also we can manually stop and re-start later if required.

In simple, these services are developed when we want everything to be done and in a same machine. In contrast to WCF services these services are not distributed in nature. We can have multiple services where in each one can perform some activities.  But as such windows services won’t provide any service to consumers. I mean in general we use windows service to do something autonomously without any other external applications interacting with it. However we can host a WCF service with in a windows service and make the WCF services available to consume within in an intranet environment.

Consider an example where in you can make use of this. You have developed an application which pushes some messages (Say Windows MSMQ or a Service broker queue). In such cases you can go with a simple windows service which runs in the background continuously monitoring the queue for the incoming messages. Once you have the message, we can simply process the same.

No comments:

Post a Comment