cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

code to republish failed jobs

gmydoor-2
10-Marble

code to republish failed jobs

Hi members,

 

Are you all aware of any code to auto republish failed jobs in windchill ?

 

 

ACCEPTED SOLUTION

Accepted Solutions

This is doable.

But we need to know how the publishing job is being triggered.

Does this pertain to ALL publishing jobs including a manual create representation?

 

I wrote some code that would publish from a workflow and return the results of the job.

In our case we needed to get the published PDF and copy it across the network to a folder but the same technique would apply here. The code still needed to determine if the publishing was successful or not.

 

In your case you need to go one more step.  You need to determine WHY it was unsuccessful. The CAD Worker did not start.

 

To get to that level of granularity you need to read the log. This is the same log displayed in the WVS Job Monitor.

 

If you need to republish ONLY if the CAD Worker does not start you can read the log that is displayed in WVS Job Monitor.

d_graham_1-1623933055939.png

 

Here's an image of a Windchill shell that has run code that gets the publishing job's log and writes the log to the shell.

This is from the same publishing job log shown above. Note the html tags.

d_graham_3-1623933372221.png

 

If the log contains the error in question such as:

"No worker can be started"

or

"Error, did not find available worker of type"

or whatever you want to trigger the republish then the code republishes the Representable.

 

BTW I also coded to republish only once. So, only two tries to publish (one initial publish and one republish). You don’t want to get into an infinite loop.

 

Hopefully this helps.

 

David

View solution in original post

9 REPLIES 9

What is the purpose of this? Normally when a job failed, it will also fail the next time.

You could create a schedule job which will check e.g. all 10min for error jobs and set them back to ready. Or you can listen to the publish event, to create a new one if it failed.

Thanks for your response. If the publishing failed due to some issue with worker then we would need to republish it. Only for that reason we are planning for auto republish.

BenLoosli
23-Emerald II
(To:gmydoor-2)

Normally when my publishing jobs fail, it is something with a timeout of the publishing settings. An automatic restart will not fix the issue behind the failure. In my case, my timeouts are set so 95% of my jobs go through and they only fasil when we get really long publishing times. My current timeouts for assemblies and drawings are over 2 hours. I had 1 assembly and drawing fail last night from exceeding the time.

This is doable.

But we need to know how the publishing job is being triggered.

Does this pertain to ALL publishing jobs including a manual create representation?

 

I wrote some code that would publish from a workflow and return the results of the job.

In our case we needed to get the published PDF and copy it across the network to a folder but the same technique would apply here. The code still needed to determine if the publishing was successful or not.

 

In your case you need to go one more step.  You need to determine WHY it was unsuccessful. The CAD Worker did not start.

 

To get to that level of granularity you need to read the log. This is the same log displayed in the WVS Job Monitor.

 

If you need to republish ONLY if the CAD Worker does not start you can read the log that is displayed in WVS Job Monitor.

d_graham_1-1623933055939.png

 

Here's an image of a Windchill shell that has run code that gets the publishing job's log and writes the log to the shell.

This is from the same publishing job log shown above. Note the html tags.

d_graham_3-1623933372221.png

 

If the log contains the error in question such as:

"No worker can be started"

or

"Error, did not find available worker of type"

or whatever you want to trigger the republish then the code republishes the Representable.

 

BTW I also coded to republish only once. So, only two tries to publish (one initial publish and one republish). You don’t want to get into an infinite loop.

 

Hopefully this helps.

 

David

 Thanks David. If possible could you share your code.

 

As a follow-up to this I wrote a utility that will detect when a publishing job fails.

I wrote it such that ONLY if the failure was due to the CAD Worker not starting a workflow Task is sent to the Admin and the user who initiated the publishing job.  Could certainly key of whatever but that seemed to be what this thread is concerned with.

 

The workflow is about as simple as it gets.

d_graham_1-1624999553755.png

 

The Task get renamed to include the identity of the object that failed to publish.

This was done to make it easily identified from the Home page.

d_graham_2-1624999845214.png

 

 

This task includes the WVS Job Monitor log as well as a link to the Representable object that filed publishing.

This was done to make it as quick and easy as possible to identify the problem.

d_graham_0-1624999474293.png

 

Some food for thought maybe?

 

David

Looks great! Just one thought. What happens if 2000 jobs are failing because of the worker? Then the user receives 2000 tasks?

 

@BjoernRueegg thanks for the reply. And good question.  The answer is dealer's choice.  I coded the tool such that a boolean  determines if additional tasks are sent or not if  there is already one running.

So, the tool can prevent multiple Tasks from showing up in the task list.

 

Let's say user1 publishes and the worker is not started. user1 and Admin get a task.

If user2 published and the worker is not started and the Tasks sent to user1 and Admin are still running only user2 gets a task.  Admin does not get a second task.

If user1 or user2 publish again and they still have their first task an additional task is NOT sent to them or Admin

 

That was the logic I came up with to keep everyone informed but also make it easy to use..

 

David

 

HM_9989503
4-Participant
(To:d_graham)

Can you send me that utility, I have the same use case

Announcements


Top Tags