Class EventUtil
java.lang.Object
com.ssgllc.fish.service.util.published.EventUtil
-
Constructor Summary
ConstructorsConstructorDescriptionEventUtil(org.springframework.context.ApplicationEventPublisher eventPublisher, com.ssgllc.fish.service.listener.CasetivityExecuteScriptEventListener casetivityExecuteScriptEventListener) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidpublishScriptEventAfterTransaction(String scriptName, Map<String, Object> data) Publishes aCasetivityExecuteScriptEventto trigger execution of a Groovy script asynchronously in a new transaction, after the current transaction successfully commits (or immediately if no transaction is in progress.
This is useful when you want to run dynamic, post-commit logic decoupled from the main transaction flow—such as sending notifications, updating external systems, or performing complex business rules—without blocking or affecting the main transaction.
-
Constructor Details
-
EventUtil
public EventUtil(org.springframework.context.ApplicationEventPublisher eventPublisher, com.ssgllc.fish.service.listener.CasetivityExecuteScriptEventListener casetivityExecuteScriptEventListener)
-
-
Method Details
-
publishScriptEventAfterTransaction
Publishes aCasetivityExecuteScriptEventto trigger execution of a Groovy script asynchronously in a new transaction, after the current transaction successfully commits (or immediately if no transaction is in progress.
This is useful when you want to run dynamic, post-commit logic decoupled from the main transaction flow—such as sending notifications, updating external systems, or performing complex business rules—without blocking or affecting the main transaction.
The script referenced byscriptNamewill be resolved and executed with the provideddatamap made available to the script under the variable namedata.
Groovy example:
eventUtil.publishScriptEventAfterTransaction('DeductProductQuantity', [ productId: '123' ])
Effect:
After the transaction commits, the script DeductProductQuantity script will be executed asynchronously with access to:
data.productId == 1234Note: Script execution happens in a separate transaction and thread, and will not impact the outcome of the original transaction.
-