Locking a service

Hi All,
Can any one tell me how lock a service.In our application,i have to execute a particular service only once.If it is executed,any service which calls this service should not execute.How do we handle this situation.

TIA

Any suggestions?
Am planning to use pub.storage:lock

Why don’t you just put a flag somewhere (database, repository, memory, …) that indicates whether the service is currently running? Then as the first step in your service you check against this flag?

=====service layout========= 
BRANCH "running" 
  true: SEQUENCE 
    EXIT from flow 
  false: SEQUENCE exit-on SUCCESS (try-catch) 
    SEQUENCE exit-on FAILURE (try) 
      set running = true 
      [service contents] 
      set running = false 
    SEQUENCE exit-on DONE (catch) 
      set running = false 
============================

Make sure to have the try-catch block in there, because otherwise your service will be locked forever when an exception occurs.

the service wm.server.query:getServiceStats allows you to get info on the services running and the number of execution threads a specific service has

cheers

Bart

or invoke via the broker this service, setting the trigger to serial processing