?
Solved

Ping (IsAlive) between two WCF windows Services

Posted on 2013-01-02
5
Medium Priority
?
1,575 Views
Last Modified: 2013-01-16
Hi Experts,

I am looking to communicate between two Services (rather two instances of the same service) on two different servers. InstanceB should periodically check if InstanceA is alive.

These services are producing services and not consuming services. Both instances would be running at the same time, but only InstanceA would be producing the needed values. Only if InstanceA fails, would InstanceB takeover.

I'm thinking of taking the 'IsAlive' approach where InstanceB checks if InstanceA is alive every 10 seconds. I've added an IsAlive() method to my contract.  Since both the Instances would be Identical, how would my code to call the IsAlive() method or config file have to change?

I would appreciate a code sample.

Thanks in advance!
0
Comment
Question by:InquisitiveMind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 1500 total points
ID: 38739709
this post answers your question:
http://stackoverflow.com/questions/2867486/is-there-an-example-of-checking-on-if-a-wcf-service-is-online

basically, it says that you don;t need ping or IsAlive or anything special to detect if service is available.
simple use exception handling to catch timeout exception (or any combination of similar exceptions) and proceed according to your requirement (switch to the backup service).
0
 
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 38739728
To just check availability/IsActive you can add a timmer in the both Services or only backup services. But it will be worth to ready following as it seems you are interested in failover/mirror services.

http://www.codeguru.com/csharp/.net/net_wcf/article.php/c19895/Introduction-to-Routing-Service-in-WCF-40.htm

and

http://stackoverflow.com/questions/3824881/design-pattern-for-wcf-client-switching-and-failover-capabilities

Thanks
0
 
LVL 25

Expert Comment

by:apeter
ID: 38741904
Is it like client will call InstanceB....and instaneB will check if instanceA is alive then it will ask InstanceA to perform and work instaed of InstanceB doing the same work ?
0
 

Author Comment

by:InquisitiveMind
ID: 38741931
@apeter:

InstanceA and InstanceB are both producing services(both auto start) and not consuming services (When I say producing services, they have a method called GenerateValues() which are generated every 15 seconds. )

Both of them are in a running state initially, but only InstanceA has the GenerateValues() method returning values to the client upon OnStart. InstanceB will not be returning the values. It should start generate values method only when a ping to InstanceA doesn't return a value. Is that any better?
0
 
LVL 25

Expert Comment

by:apeter
ID: 38742010
then below might work ?
         if (InstanceAProxy.IsAlive())
                       InstanceAProxy.GenerateValues()
          else  if  (InstanceBProxy.IsAlive())
                       InstanceBProxy.GenerateValues()
          else
                  //what happens

But why InstanceA is not always live ?
0

Featured Post

Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question