Dear Alex, Does DO4 has Dataservices and runtime services. i could not find any information in help manuals. i am testing DO4 but could not find any info for this feature like in DO 3.x.


Updated at 15.06.2010 10:14:52

Thanks Alex for your reply. Can you please give me a brief idea how i can start writing my own runtime services in DO4, or else i will have to depend on windows scheduled task / windows services to do the peridoic calcualtions/ jobs for me. which i dont want.


This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked Jun 15 '10 at 07:44

HannanKhanji's gravatar image


One Answer:

Runtime Services aren't supported in DO4, so you should implement this by your own.

Regular Domain and Session-level services are supported. If you're using default IoC container integrated into Xtensive.Core (that's the case you have by default, although they're replaceable as well), all you should do is to apply this attribute to your service type: [Service(typeof(RequestedServiceType))], where RequestedServiceType must be its base type. Our integrated IoC framework relies on two attributes:

  • ServiceAttribute. As you see, by default services are singletons, byt this is overridable. If service isn't singleton, its instance is created on each new request of it.

  • ServiceConstructorAttribute. It marks the constuctor we must use to create service instance. If there are arguments, they're resolved via IoC containers as well (i.e. you can consume other services from your constructor).

To get Session-level or Domain-level service, you must use the following code:

// Session-level service:
var mySessionService1 = session.Services.Get<MySessionService>(); // returns null, if there is no requested service
var mySessionService2 = session.Services.Demand<MySessionService>(); // either an object or exception; Demand is an extension method to IServiceContainer
// Domain-level service:
var myDomainService = domain.Services.Demand<MyDomainService>();

session.Services and domain.Services here is an IoC container providing these services.

Also note that:

  • If you inherit your service from SessionBound (or will implement ISessionBound), you'll be able to rely on its Session member; Session activation will work for its methods as well.

  • Session and SessionHandler are available as services from Session.Services IoC container. So you can use them as constructor arguments for other Session-level services.

  • Domain and DomainHandler are available as services from Domain.Services IoC container. So you can use them as constructor arguments for other Domain-level services.

Some examples of intagrated Session-level services:

All you need is background thread (or threads) performing some tasks by schedule - I'm not sure if there is anything special to DO at all...

Few hints:

  • I think you should decide what kind of scheduler you need first: transactional or simple in-memory scheduler. DO39 was providing just simple scheduler, but in some cases it's a good idea to use a transactional one - e.g. when you need to execute some tasks pretty rarely, but the execution itself must be guaranteed to occur.
  • The easiest way to build a transactional sceduler is to implement persistent ScheduledOperation type ;)
  • Use priority queue to implement in-memory scheduling effeciently. Xtensive.Core already contains PriorityQueue implementation, documentation is here.

answered Jun 15 '10 at 09:47

Alex%20Yakunin's gravatar image

Alex Yakunin

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview


Once you sign in you will be able to subscribe for any updates here



Asked: Jun 15 '10 at 07:44

Seen: 2,343 times

Last updated: Jun 15 '10 at 07:44

powered by OSQA