JetBrains / JetBrains/Exposed

Chaining multiple suspended transactions

Open
#1,477 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Kotlin
Stars
9.3k
Forks
798
Avg merge
4d 2h
Merged PRs (30d)
26

Description

Hi,

I have a service that opens a newSuspendedTransaction() at the top level. Thereafter, there are numerous calls across multiple service and DAOs that open their own transactions.

If I want to commit or rollback across all these services and DAOs, at the top level service that initiated the chain, how do I go about doing that?

I'm essentially looking for transaction propagation.

```
newSuspendedTransaction {
suspendedTransaction {
commit()
}
suspendedTransaction {
commit()
}
....
rollback()
}
```

The above code works. That is, the last rollback() at the top level transaction, rolls back all the child transactions.

But my problem is that all the code that forms the child suspended transactions are not available in one block, in one method.

They are dispersed/delegated across several services and DAOs. How do I go about having transactions in those child services and DAOs "participate" in the parent transaction?

The entire chain uses suspend functions.

Are there any examples of this?

Thanks.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.