Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to execute workflow custom process steps in a single thread?

Avatar

Level 1

Hi There

We have a use case where the launcher is triggering workflow which in turn triggers another custom workflow. The launcher is triggered by a node update which happens via a translation connector which triggers the launcher and executes workflow.

Sometimes the frequency of updating a single node by translation connector multiple times is so fast that it triggers the launcher and triggers another workflow on the page multiple times even though I've put a check to execute logic when the page is not subject to  workflow.

So, if logic is executed for a page means workflow has already been triggered meaning logic again should not be executed because page is already subject to workflow but due to quick processing it's triggering again because workflow check returns false.

Is there any way entire code can be executed in a single thread so process step processing happens after the completion of previous one?

I already tried adding the entire custom process code inside "Executor newSingleThread" but still it triggers multiple threads.

Is there any way to restrict it?

Or another thing, is there anyway that if a page is subject to workflow then do not trigger another workflow on it? As I can see, the page can be subject to more than one workflow.

1 Accepted Solution

Avatar

Correct answer by
Level 6

Hi @sumanthaem42 This is happening because your node is frequently updated by translator and workflow is getting triggered on each update. Even you make is single threaded, your problem is not resolved. You are creating a new workflow instance every time. 

I can think of one solution, Check at what update, you want to trigger workflow. Means your node must be updating(add/remove/update property) multiple time. Identify that update you want that workflow to be triggered. Create an event handler and trigger workflow using code as required condition. 

You can think of as per your use case.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 6

Hi @sumanthaem42 This is happening because your node is frequently updated by translator and workflow is getting triggered on each update. Even you make is single threaded, your problem is not resolved. You are creating a new workflow instance every time. 

I can think of one solution, Check at what update, you want to trigger workflow. Means your node must be updating(add/remove/update property) multiple time. Identify that update you want that workflow to be triggered. Create an event handler and trigger workflow using code as required condition. 

You can think of as per your use case.

Avatar

Level 5

@sumanthaem42 I think so it can be achieved using the below steps:

1. Change the launcher render condition to not trigger the workflow under your project specific path.

2. Create a custom scheduler, which will fire the query and get the list of the updated paths.

3. Then you can iterate the list and run the specific business use-case.

 

With this even if there are multiple operations on the same page before the scheduled time, there will be only one time execution for the path.

This is improve the performance as well for the system. But make sure that the oak:index are created for the query execution to be performed in Step2. And the scheduler runs during the off-load.

 

Thanks