KBEC-00004 - Serializing a process across multiple agents

Article ID:360032832752
1 minute readKnowledge base
On this page


Make sure only one job at a time can run a process. The process itself can run on any agent, not on a fixed agent only.

Some processes can be run in a single instance at a time only. For example, you might want to limit checkins to a source control system so only one job at a time can be running the checkin. However, when the process is allowed to run, the checkin can be run from any agent. It is not "locked" to a particular resource.

The solution approach is to set up a resource called "TokenResource" that represents the serialized process. However, this is not the resource that will be used to run the checkin or other process. The actual checkin step will be wrapped with two other steps. The first wrapper step acquires the TokenResource and marks it as "Retain Exclusive". After the real step is run, the second wrapper step releases the TokenResource.


Create a resource named "TokenResource"

Create a resource that points to any "localhost". If you need to serialize different operations, create several of these resources with different names. These resources will not interfere with each other, or with other jobs running on "localhost".


Resource name: TokenResource
    Host name: localhost

Create a procedure to call your step with a wrapper


Step 1: AcquireToken
             Resource: TokenResource
     Retain Exclusive: checked

Step 2: YourStep
             Resource: (your resource)
              Command: (your command)

Step 3: ReleaseToken
             Resource: TokenResource
    Release Exclusive: checked

Depending on what else your job needs to do, you can call this procedure directly, embed these steps in another procedure, or call this procedure as a sub-procedure call from another procedure.