Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

In what order job types are processed? (default job types and user-defined)

7 REPLIES 7
Reply
Message 1 of 8
simmelmann
704 Views, 7 Replies

In what order job types are processed? (default job types and user-defined)

When the status transition from e.g. "in progress" to "released" triggers the following jobs:

--> Autodesk default job type: Synchronize properties with job server and update view and PDF

--> user-defined job type: Enter current Vault User and current date in Vault properties (24_Checked_From and 23_Checked_Date)

In what order the job types are processed?

Do your answer apply to Vault versions 2018 to 2021?

Is independent of the object (file, Item)?

7 REPLIES 7
Message 2 of 8
Markus.Koechl
in reply to: simmelmann

My answer applies to all Vaul versions that you asked for.

You can more or less never predict a precise order of job execution. The reason is the principle of putting jobs with an execution priority into the queue and that multiple job processors can grab specific jobs only. But I stop writing here because I link you to a comprehensive and clear description in the SDK documentation. Open the API Documentation "C:\Program Files\Autodesk\Autodesk Vault 2021 SDK\docs\VaultSDK.chm" and search for "priority": the first result is the Knowledgebase article.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
Tags (1)
Message 3 of 8
simmelmann
in reply to: Markus.Koechl

First of all, thank you very much for your reply and apologies for the delay in my reaction.

I read the chapter in the API documentation and discussed it with our programmer. This leads to a final question ...

The documentation says:

You have 3 tasks (A, B and C) which you want to complete in order.  So you queue up all three jobs at once, giving A a priority of 1, B a priority of 2 and C a priority of 3.  Now you are guaranteed that they will get executed in order, right?

Wrong 

Because there may be multiple Job Processors running and because Job Processors can be specialized by type, you are not guaranteed the order.  It's technically possible for C to get executed first, with B second and A last.  Or any other permutation.

 

The reason for this is that when using multiple JobServer computers, it cannot be predicted in which order the job types will be processed. So far understandable. Does the reverse apply?

If only 1 JobServer / 1 computer is in use, the job types will be processed with the priority that has been assigned to them.

Conclusion: The priority that can be assigned to a job type is only guaranteed if one job server exclusively processes all job types.
This is "only" a restriction - not a "KO criterion".
Do you agree with me?
I would be pleased about an answer.

Message 4 of 8
Markus.Koechl
in reply to: simmelmann

Agreed. You can predict the order for configured pairs of job processor/job types, e.g. running all custom jobs on a single job processor A will leverage the (custom) priority while all default jobs running on other job processors B, C, ... (no custom jobs enabled).


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
Message 5 of 8
simmelmann
in reply to: Markus.Koechl

Since a more or less complex programming effort is involved, I stay with the topic until I understand. It is time for a specific example:

Vault on only 4 (!) CAD workstations. Vault configuration uses files and items, No ECOs yet.

1 PC is available as job server = 1 job processor

 

Subtask 1: Vault User „Designer“ releases IDW. An Addin writes the current user to the file property (used in title block) before  the release process takes place = BEFORE the action of the job processor. After this, the Autodesk job type " Update views with JobProcessor and create PDF" (job type A) is processed.

Consequence: there is an IDW.PDF displaying the last user „Designer“ in the title block.

As far as already implemented and working...

 

Subtask 2 = Item release

Vault User „Approver“ releases item.

The status transition should trigger

... a user-defined job (job type B) at first:  writes the Vault User to the file property "Approver“

... then processing the Autodesk job type "Update views with JobProcessor and create PDF" (job type A)

It must be ensured that the sequence is exactly as described so that the „Approver“ can be seen in the title block of the IDW.PDF.

 

I have to decide if I want to use an addin for subtask 2, or more elegantly a custom job.

What is the recommendation for this sequence-sensitive task?

Addin or user-defined job?

Message 6 of 8
smilinger
in reply to: simmelmann

I have a not-so-elegant solution to ensure the execution order of the custom jobs even in the scenario of multiple job processors.

 

In each custom job handler, you can use GetJobsByDate to retrieve current pending or running jobs, and check if any prerequisite job is pending or running, if the answer is no, execute the current job, otherwise, abort the current job and use AddScheduledJob to reschedule the current job a couple of minutes later.

 
The code should look like this:

 

if (CheckPrerequisiteJob(file))
{
    JobSvc.AddScheduledJob(type: job.JobType,
                            desc: job.Description,
                            paramArray: job.Params.Select(p => new ACW.JobParam { Name = p.Key, Val = p.Value }).ToArray(),
                            priority: 100,
                            execDate: DateTime.Now.AddMinutes(5),
                            execFreqInMinutes: 0); // 0 means the job will only run once
    context.Log("Prerequisite job is not finished, reschedule the job in 5 minutes.", ACJE.MessageType.eInformation);
    return ACJE.JobOutcome.Success;
}

 

 

Message 7 of 8
smilinger
in reply to: smilinger

There is also another solution to your situation.

 

You can manually trigger the "update view and pdf" job at the end of your custom job, instead of let vault do it. You can decide to trigger the job only if your custom job is successful.

 

Also, for your subtask 2, please be aware that there is no built-in "update view and pdf" job for item release, because such job type is only for files, not for items. The transition configuration dialog may make you think there is, but that is not true, you need to do it all on your own.

 

You can trigger the "update view and pdf" job like this:

 

if (MyJobSuccess)
{
    var jobParams = new[]
    {
        new JobParam { Name="FileVersionIds", Val = file.Id.ToString() },
        new JobParam { Name="QueueCreateDwfJobsOnCompletion", Val = "True" },
        new JobParam { Name="QueueCreatePdfJobsOnCompletion", Val = "True" }
    };

    JobSvc.AddJob("Autodesk.Vault.SyncProperties", $"Synchronize Properties: {file.Name}", jobParams, 100);
    return ACJE.JobOutcome.Success;
}

 

In this way you can just enter your custom job type name in the custom job type list of the transition configuration dialog, you don't need a client-side add-in. However, be aware that the JobParam names for the built-in job type are an implementation detail of vault, they could be changed in future releases.

Message 8 of 8
simmelmann
in reply to: smilinger

Hello, smilinger,

Thank you very much for these constructive suggestions. As I understand it, your solutions describe exactly what I want to achieve.

I will share this information with my colleagues and I will definitely give feedback here when the first tests are done.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report