BPT - Wait activities didn't closed as expected with the update to an entity

BPT - Wait activities didn't closed as expected with the update to an entity

  

Hi,

I'm facing an odd behaviour with a BPT process.

Here are the facts:

  1. I had 500 Wait activities with status Waiting
  2. They close with an update to a row in a given entity 
  3. I did the update directly in the DB myself
  4. 480 of the Wait activities closed as expected
  5. 20 Wait are still in status Waiting
  6. There is no callback in this specific Wait (an exception could be being raised but it's not the case)
  7. There is no Error_Id in OSSYS_BPM_ACTIVITY for these activities
  8. All the BPT threads are Idle (Activity Processor, Event Processor)


What am I missing here?

I tried repeating the update several times with no effect. The 20 remaining Wait activities kept their waiting state.


Thanks in advance for any feedback you may give me.


Hi João,

Are you using different tenants/user providers in your application? Be sure that the entity is multi-tenant and the module with the process is using the same User Provider the process/activity.

Hi Joao,

Did you commit that update transaction? A wait activity can bw cloase other ways - timeout or using API.

regards

Mi

Mental Image wrote:

Hi Joao,

Did you commit that update transaction? A wait activity can bw cloase other ways - timeout or using API.

regards

Mi

Sure I did!

I know there are other ways. The one that's implemented is the Close On Update of an entity.


Yesterday I had some more fixing to do and I experienced the same behaviour.

I have x sub-processes (all with a parent process), each one in the same point of the flow - a Wait activity.

I did the manual update in the DB and I could see the activities being closed in the Process Monitor and then some of them remaining in the Wait and not going forward...


 


Hi João,


Any news regarding your findings?

Did you get to any conclusion?

Solution

@Daniel

Well, I had to terminate the Activities manually and hadn't had the time to go back to it.

But I still have the ocasional nightmare about it ;)

If I ever find something more I'll update the post.

Solution

Hi João,

Updating rows in your entity will generate events in the BPT event queue (system entity) that need to be processed for the activities to close. You may have experienced some issue where the events weren't all processed.

Next time you need to do something like this, be sure to keep an eye on the "Processes Events" column in Environment Health (and also on the error log) and check if you are left with events queued or in error.

Hi João

We are having several problems related the database transactions when we update a record, inside another logic action but apparently in the end of the action that updated the record, the transaction is not committed.

In this case, now we are always expliciting committing the transaction by before call any action activity.

Best regards

Tiago Vital

Tiago Bojikian da Costa Vital wrote:

Hi João

We are having several problems related the database transactions when we update a record, inside another logic action but apparently in the end of the action that updated the record, the transaction is not committed.

In this case, now we are always expliciting committing the transaction by before call any action activity.

Best regards

Tiago Vital

Hi Tiago,

Keep in mind that BPT activities execute in a separate database transaction, so there is no guarantee data you just created/updated in your entities will be there, unless you perform that explicit commit right before calling into any BPT activity/process (I'd say this is actually a best practice).

Paulo Cunha wrote:

Tiago Bojikian da Costa Vital wrote:

Hi João

We are having several problems related the database transactions when we update a record, inside another logic action but apparently in the end of the action that updated the record, the transaction is not committed.

In this case, now we are always expliciting committing the transaction by before call any action activity.

Best regards

Tiago Vital

Hi Tiago,

Keep in mind that BPT activities execute in a separate database transaction, so there is no guarantee data you just created/updated in your entities will be there, unless you perform that explicit commit right before calling into any BPT activity/process (I'd say this is actually a best practice).

Yes.

Thank João. 

Best regards 

Tiago Vital 


Hello Everyone,


I have a related question.

Does the 'Wait' event work with advanced SQL query ?

Say - I have defined a 'Wait' event to close on update of some entity. 

Now - lets say instead of the "UpdateEntity" action (which Outsystems generates) , say that I update the entity using an advanced SQL query.

Then will the 'Wait' event still get closed? Please let me know.

 @Chetan Yewale

Yes, it should work.

João Heleno wrote:

 @Chetan Yewale

Yes, it should work.

Thank you.


Just to second João's reply:

It will work since the event is triggered at the database level when the row is updated (doesn't matter how the database update is executed)

João Heleno wrote:

 @Chetan Yewale

Yes, it should work.

Hello,

I have a related question too. 

What if I use (consume) an API Instead of an entity? 

I'm having problem making the Wait event close when I receive the expected response from the service. 

If the problem is because I'm using an api on the Wait onclose, what would be the work around?

Thanks 


Hello Nivaldo,

The "On Close" event in a Wait can be triggered by an update in an entity (selected in the CloseOn property) or when the Timeout specified for the activity is reached (check the docs for more details: https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Processes/Process_Tools/Wait).

So, you have a few of options to react to a response from a service:

  • Write the service response to an entity (it can be one just for this) and then set the Wait "Close On" property to the update of this entity. This way anytime you update that entity the wait will be closed. This would be my preferred approach.


  • Set a Timeout in the Wait activity and then inside the "OnClose" event action check if the service has responded already (by checking some entity where you store the response or status). If service hasn't responded, you can raise an exception inside the "OnClose" (e.g. Abort Activity) and the Wait will retry to close after the timeout.


  • Wait can also be explicitly closed by using the ActivityClose action (from System), although I wouldn't recommend you to use this approach in most cases.


Check this doc for more on designing wait activities: https://success.outsystems.com/Documentation/10/Developing_an_Application/Use_Processes/Patterns_for_Designing_Processes/Designing_Waiting_Activities

Hope this helps!