Lifecycle event jobs

Here are some important things you need to know about the new Vault 2011 feature that allows you to queue up a job on a lifecycle state change.

Configuring the system
Obviously you need to have the Job Server enabled.  So that's the first step.  You can enable this feature in the Global admin settings.

The next thing you need to know is that each life cycle transition has 0 to N custom jobs associated with it.  When a file moves through a transition, a job will be added to the queue for each association. 

To set up which jobs fire for which transitions, I suggest using the Lifecycle Event Editor, which is included in the util directory of the SDK.  You can also use the Web Service API function UpdateLifeCycleStateTransitionJobTypes in Document Service Extensions. 
My Vault 2011 SDK video tour has a demo of the Lifecycle Event Editor.

Keep in mind that this mechanism only applies to custom job types.  The built-in job types, property sync and DWF generate, are configured through different mechanisms. 

Common pitfalls

  • Events are not handled in real time.  The job will instantly go on the queue after the file moves through the transition.  However, you don't know when the job will get processed.  If there is a large backlog, it might be hours before your handler runs.
  • Jobs are fired on a per-file basis.  For example, let's say you want to send out an email when a file gets released.  If someone Releases a 1000 part assembly, it will result in 1000 jobs on the queue.  You need to make sure that your handler doesn't send out 1000 emails.  Much better is to send out 1 email listing the 1000 files.
  • Transitions are specific to a lifecycle definition.  For example, if you set the jobs for WIP->Released in the Flexible Release Process, it will have no impact on files using the Basic Release Process.

Writing the job handler

Any job put on the queue this way will have two parameters.  It will have the "FileId" value and the "LifeCyleTransitionId" value.  These two pieces of information should allow your code to find out anything else it needs to.

Again, your handler might be running hours after the file was transitioned, so you should handle cases like the file being deleted, or the File ID not pointing to the latest version.

Other than that, things should be the same as any other job handler. See the SDK documentation for more information of the Job Processor API.


Comments

4 responses to “Lifecycle event jobs”

  1. MaxU77 Avatar
    MaxU77

    Doug,
    If there a way (apart from ECO workflow) to get notification about publishing new Item revisions?

  2. There is no built in way. But if the new revision comes from a state change, then you could write a job handler to send out the email. Watch Folder uses a similar concept.

  3. Hi Doug. Not sure if you still monitor comments from 5 year old threads, but this seemed relevant.
    I have been migrating one of our tools that used ItemLifecycleExtension in the olden days to use the job processor.
    This is one of those scenarios where now, the system might create 1000 individual jobs rather that one job with a bunch of items.
    Are there any examples, patterns or other suggestions for how to queue up jobs, and perhaps execute them every 5 minutes (knowing that there’s a chance you could lose them if the job server was closed)?
    Thanks,
    Matt

  4. Hey Matt. I get alerts when new comments are posted, regardless of how old the post is.
    Anyway, one possible solution is to not use JobProcessor, which handles one job at a time. I have another post describing how you can build your own service to read jobs off the queue. This allows you to get around the limitations of JobProcessor. http://justonesandzeros.typepad.com/blog/2013/02/custom-jobs-without-job-processor.html
    For example, your service could reserve 50 jobs at a time, process them all together, then mark the 50 jobs as complete.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading