0

I am creating a library of "smart" components that communicate. A master controller process can be used which can create a process or start a service that contains a communicator. The created entity is assigned a port number by the master which can then send it XML messages using http. My problem is this: suppose the master object crashes, and is restarted. I can iterate over the services and processes and match names, but how can I recover the port number I assigned to the child processes / services?

I considered writing a list of pairs - process ID and port # - to a hidden file which can be reloaded on startup, but because process IDs are not necessarily unique (only for the duration of the process itself) that doesn't seem robust. I can retrieve the port number from a process because I can just query the argument array used to create it, but that doesn't work for a service. Any thoughts on where the port number for each child can be stashed so I can recover it?

2
  • HTTP is probably the wrong protocol to use for this. Have you looked at MSMQ? May 31, 2012 at 18:41
  • Yes I did look at queues, was quite taken by them for a while. Might migrate to them if I can prove the architecture works. May 31, 2012 at 18:49

2 Answers 2

0

Services can use arguments, and you can query a process running for the arguments used to start the process (using WMI).

2
  • I know I can get the process from the ServiceController - so are you saying that the arguments passed in via ServiceController.Start( string [] args ) can be obtained from the process? Surely not? May 31, 2012 at 18:54
  • You may be right, but I know that if I manually start a process or the process is set to auto-start that I can get the arguments it started with (beyond looking in the registry for the service). I'm not sure how ServiceController.Start() would be any different. I would recommend looking at stackoverflow.com/questions/6182801/…. May 31, 2012 at 19:14
0

I suppose you are using WCF, in which case, depending on your network, WCF Discovery may be an option.

The Discovery APIs provide a unified programming model for the dynamic publication and discovery of Web services using the WS-Discovery protocol. These APIs allow services to publish themselves and clients to find published services. Once a service is made discoverable, the service has the ability to send announcement messages as well as listen for and respond to discovery requests. Discoverable services can send Hello messages to announce their arrival on a network and Bye messages to announce their departure from a network. To find a service, clients send a Probe request that contains specific criteria such as service contract type, keywords, and scope on the network. Services receive the Probe request and determine whether they match the criteria. If a service matches, it responds by sending a ProbeMatch message back to the client with the information necessary to contact the service.

To be more specific, it seems to me you are trying to reimplement the WCF Discovery Proxy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.