Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0050421Openbravo ERPA. Platformpublic2022-10-05 14:262022-10-05 14:32
vmromanos 
Triage Platform Base 
normalmajoralways
newopen 
5
 
 
Core
No
0050421: Push API payload generation when event is triggered
As far as I understand, right now the Push API works this way:

1. A push API event is triggered in the middle of a transaction, pointing to the object id. For example:
   SynchronizationEvent.getInstance()
        .triggerEvent("OBDOAPI_UpdateDOStatus", distributionOrder.getId());
2. The transaction finishes
3. The EDL request is executed sending the PUSH API event to the listeners. In the moment it is sent, the payload is generated and sent outside.


So the process is pure asynchronous, and this might lead to inconsistencies.
Real example:

We have two events related to Distribution Orders:
 * OBDOAPI_UpdateDOStatus --> which is triggered when a DO changes the status
 * OBDOAPI_UpdateDOQuantities --> which is triggered when any quantity in the DO changes when a goods movement is performed.

See this real flow:
1. A DO is confirmed.
 1.1 The OBDOAPI_UpdateDOStatus is launched with Confirmed status [OK]
2. A "skip delta" action is performed in the DO. This implies to do the following stuff in the same transaction:
 2.1 to create a goods movement. The OBDOAPI_UpdateDOQuantities is launched and the status is Closed [WRONG, at this point the status is Confirmed]
 2.2 to close the DO. The OBDOAPI_UpdateDOStatus is launched and the status is Closed [OK]



So the problem is at 2.1, where I was expecting to receive the Confirmed status, because in the moment it was triggered that was the status.
However, I'm receiving Closed status, because in the moment the EDL is executed, this is the status in the DB
Configure the preference AWO Close DO Issue automatically after Skip Delta = Y


Create a DOi with one line of 10 units
  --> #1.json# OBDOAPI_UpdateDOStatus is launched with status Confirmed [OK]


Generate the picking for 10 units and confirm it.

Generate the issue task, and confirm 3 units from AWO Frontend. Important: select Skip delta.
  ---> #2.json# OBDOAPI_UpdateDOQuantities is launched with 3 units and status Closed [WRONG: I'm expecting Confirmed Status at this point]
  ---> #3.json# OBDOAPI_UpdateDOStatus is launched with 3 units and status Closed


JSON files attached
When triggering the event, being able to indicate that I want to generate the payload at this exact moment, save it to the EDL, and use it when sending it to the subscribers.
No tags attached.
related to defect 0050249 closed AtulOpenbravo Modules Close DO can be launched from two different places, creating problems in Push API 
zip refirstsmcpbug.zip (2,343) 2022-10-05 14:26
https://issues.openbravo.com/file_download.php?file_id=17588&type=bug
Issue History
2022-10-05 14:26vmromanosNew Issue
2022-10-05 14:26vmromanosAssigned To => Triage Platform Base
2022-10-05 14:26vmromanosFile Added: refirstsmcpbug.zip
2022-10-05 14:26vmromanosModules => Core
2022-10-05 14:26vmromanosTriggers an Emergency Pack => No
2022-10-05 14:27vmromanosRelationship addedrelated to 0050249
2022-10-05 14:32vmromanosSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=24830#r24830

There are no notes attached to this issue.