Pieter van Ginkel
Pieter van Ginkel

Reputation: 29632

Starting self hosted WCF services on demand

Is it possible to start self hosted WCF services on demand?

I see two options to accomplish this:

I cannot use IIS or WAS because the web services need to run in process with the UI business logic.

Which is feasible and how can I accomplish this?

EDIT:
I cannot just start the service hosts because there are hundreds, most (about 95%) of which are (almost) never used but need to be available. This is for exposing a business logic layer of 900 entities.

Upvotes: 0

Views: 1108

Answers (2)

Pieter van Ginkel
Pieter van Ginkel

Reputation: 29632

Went the following route:

  • Create a single service host;

  • Create a dynamic proxy which implements all service interfaces;

  • Add a service endpoint for every interface the dynamic proxy implements;

  • Dispatch to the correct implementation from the dynamic proxy.

Upvotes: 1

RQDQ
RQDQ

Reputation: 15569

You could do a locator service setup. Basically always expose a lightweight service that returns the address of the 'actual' services. Every time the address of a particular service is requested, go ahead and spin it up.

If you're worried about cleaning it up, you could keep a list of the service hosts and wire in some sort of inactivity timeout so you could periodically shut down the service hosts.

There are some design concerns here - the concept of "calling one service before you call another one" is probably considered a bad idea on some level (sounds like coupling the state of two services).

Upvotes: 1

Related Questions