Dr-Dream opened a new issue, #6875:
URL: https://github.com/apache/incubator-kie/issues/6875

   ### Describe the bug
   
   If running persistence sonataflow in that only produces events in transition 
an in the end it produced in reverse order.
   Example flow
   ```yaml
   id: vzhukh-processor
   version: "1.0"
   specVersion: 0.8.0
   name: Hello World
   description: Description
   start: ReceiveAndProcess
   events:
     - name: VzhukhInputEvent
       type: vzhukh.text.v1
       kind: consumed
       correlation:
         - contextAttributeName: chattype
         - contextAttributeName: chatid
         - contextAttributeName: messageid
     - name: VzhukhOutputEvent
       type: vzhukh.text.processed.v1
       kind: produced
       source: vzhukh-processor-source 
       correlation:
         - contextAttributeName: chattype
         - contextAttributeName: chatid
         - contextAttributeName: messageid
     - name: VzhukhProcessEvent
       type: vzhukh.text.processing.v1
       kind: produced
       source: vzhukh-processor-source 
       correlation:
         - contextAttributeName: chattype
         - contextAttributeName: chatid
         - contextAttributeName: messageid
   states:
     - name: ReceiveAndProcess
       type: event
       onEvents:
         - eventRefs:
             - VzhukhInputEvent
       transition:
         nextState: ReceiveAndProcess2
   
     - name: ReceiveAndProcess2
       type: operation
       actions:
         - eventRef:
             triggerEventRef: VzhukhProcessEvent
             data: '{ "data": . , "type": "processing-2", "test": "some test" }'
       transition:
         nextState: ReceiveAndProcess3
   
     - name: ReceiveAndProcess3
       type: operation
       actions:
         - eventRef:
             triggerEventRef: VzhukhProcessEvent
             data: '{ "data": . , "type": "processing-3", "test": "some test" }'
       transition:
         nextState: EmitResult
   
     - name: EmitResult
       type: operation
       actions:
         - eventRef:
             triggerEventRef: VzhukhOutputEvent
             data: '{ "data": . , "type": "output-1" }'
       end:
         terminate: true
         produceEvents:
           - eventRef: VzhukhOutputEvent
             data: '{ "data": . , "type": "output" }'  
   ```
   
   
   ### Expected behavior
   
   At least in logs an in sink expected that after flow start events produced 
in flowing order
   publishing type=processing-2
   publishing type=processing-3
   publishing type=output-1
   publishing type=output
   
   
   ### Actual behavior
   
   according to logs and knative broker events produced exactly in reverse order
   publishing type=output
   publishing type=output-1
   publishing type=processing-3
   publishing type=processing-2
   
   
   ### How to Reproduce?
   
   1. run flow in dev mode
   2. ```shell
   curl --location 'localhost:8080/' \
   --header 'ce-source: my-payment-gateway' \
   --header 'ce-type: vzhukh.text.v1' \
   --header 'ce-id: pay-12345' \
   --header 'ce-chattype: telegram' \
   --header 'ce-chatid: 123' \
   --header 'ce-messageid: 456' \
   --header 'Content-Type: application/json' \
   --data '{
       "text": "text"
   }'
   ```
   3. Check logs an sink
   
   ### Output of `uname -a` or `ver`
   
   Darwin 25.5.0 Darwin Kernel Version 25.5.0: Tue Jun  9 22:26:15 PDT 2026; 
root:xnu-12377.121.10~1/RELEASE_ARM64_T6031 arm6
   
   ### Output of `java -version`
   
   java version "25.0.2" 2026-01-20 LTS Java(TM) SE Runtime Environment Oracle 
GraalVM 25.0.2+10.1 (build 25.0.2+10-LTS-jvmci-b01) Java HotSpot(TM) 64-Bit 
Server VM Oracle GraalVM 25.0.2+10.1 (build 25.0.2+10-LTS-jvmci-b01, mixed 
mode, sharing)
   
   ### GraalVM version (if different from Java)
   
   _No response_
   
   ### Kogito version or git rev (or at least Quarkus version if you are using 
Kogito via Quarkus platform BOM)
   
   10.2
   
   ### Build tool (ie. output of `mvnw --version` or `gradlew --version`)
   
   _No response_
   
   ### Additional information
   
   Actually this problem comes from fact that transactional publisher is used 
an it is joined to transaction so actual publishing done on AFTER_SUCCESS
   
https://github.com/apache/incubator-kie/blob/main/kogito-codegen-modules/kogito-codegen-events/src/main/resources/class-templates/events/TxEventEmitterQuarkusTemplate.java#L79
   
   But in JTA this sync event produced for joined resources in reverse order, 
what is implemented in narayana JTA
   
https://github.com/jbosstm/narayana/blob/main/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java#L504
   
   So actually it is 'there is no guarantee of exact order' but 'here guarantee 
of wrong order' :).
   
   So it seems to me that this behaviour needs to be reviewed and refactored.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to