Thanks for your message.

I'll be happy to answer *specific *questions (related to jOOQ) in case you
run into issues. On such a high level, I don't think this is the right
forum for your generic question about using Spring asynchronous
transactions.

Thanks,
Lukas

On Fri, Jun 16, 2023 at 3:06 PM Velmurugan A <velmuruga...@trimble.com>
wrote:

> Hi Team,
> I'm working in Spring boot. I need to pass my current Transaction to
> completableFuture thread. So that it could use on live data as well as it
> will roll back if any error in the main thread. please guide me that how
> can we do this ?
>
> On Friday, February 12, 2021 at 12:57:37 PM UTC+5:30 Lukas Eder wrote:
>
>> I really recommend you don't use Spring's @Transactional annotation if
>> you must use asynchronicity, as it will always bind transactions to
>> threads. Some additional insight can be found here as well:
>> https://github.com/spring-projects/spring-boot/issues/24049
>>
>> Yes, using the jOOQ transaction API is what I suggested. The
>> "configuration" in your example will contain a DefaultConnectionProvider
>> which will not return the Connection to the connection pool for as long as
>> the transaction runs. Based on this "configuration" (and its underlying
>> connection), you can now continue using jOOQ API, including the
>> asynchronous one. Notice that depending on the thread safety guarantees of
>> the underlying JDBC driver, you might still have to make sure your threads
>> do not access the JDBC Connection concurrently. I.e. your asynchronicity
>> should be implemented in a strictly sequential way.
>>
>> Notice that the transaction itself will still block the calling thread.
>> If you want to avoid that, you might as well just make the entire
>> transaction asynchronous using DSLContext::transactionAsync, and then not
>> worry about the transaction contents.
>>
>> I hope this helps,
>> Lukas
>>
>> On Fri, Feb 12, 2021 at 7:48 AM Apoorv Naik <naik....@gmail.com> wrote:
>>
>>> Ok, let's try and fix the code together then.
>>>
>>> @Override
>>> @Transactional(propagation = Propagation.NESTED)
>>> public Boolean save(Long version, ReconciliationResult 
>>> reconciliationResult) {
>>>
>>> ....
>>> }
>>>
>>> So here's the main method that interacts with the DSL context object,
>>> from the Javadocs it looks like @Transactional doesn't support propagation
>>> to the transaction context to any spawned threads.
>>>
>>> I am guessing the best bet is to call the transaction API provided by
>>> Jooq, will the threads spawned from the 
>>> *dslContext.transaction(configuration
>>> -> { ..// threads spawned here }); *have access to the same transaction.
>>>
>>> *Apoorv Naik*
>>>
>>>
>>> On Thu, Feb 11, 2021 at 10:40 AM Lukas Eder <lukas...@gmail.com> wrote:
>>>
>>>> No, we don't have such a wiki yet
>>>>
>>>> On Thu, Feb 11, 2021 at 6:35 PM Apoorv Naik <naik....@gmail.com> wrote:
>>>>
>>>>> Yes, you're right, I'm using the standard spring data source backed by
>>>>> HikariCP and relying on JooqAutoConfiguration to do the rest. Do you have 
>>>>> a
>>>>> detailed wiki or manual for creating a custom data source / connection
>>>>> provider that would support what I need?
>>>>>
>>>>> I want to give it a shot before having you take a look at it.
>>>>>
>>>>> *Apoorv Naik*
>>>>>
>>>>>
>>>>> On Thu, Feb 11, 2021 at 3:22 AM Lukas Eder <lukas...@gmail.com> wrote:
>>>>>
>>>>>> You're probably running this code with a standard, thread-bound
>>>>>> DataSource such as e.g. Spring is offering. This means that each of these
>>>>>> async threads will spawn a new transaction, because that's how this
>>>>>> DataSource works.
>>>>>>
>>>>>> You will need to implement a DataSource, or a jOOQ ConnectionProvider
>>>>>> that can handle this, or if you're using jOOQ's transaction API (async or
>>>>>> not), the Configuration available to the transactional scope will always
>>>>>> use the same Connection instance, which holds the transaction.
>>>>>>
>>>>>> I'll be happy to review actual code if you're interested.
>>>>>>
>>>>>> Thanks,
>>>>>> Lukas
>>>>>>
>>>>>> On Wed, Feb 10, 2021 at 11:20 PM Apoorv Naik <naik....@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> I was experimenting with performing writes using the runAsync
>>>>>>> construct. What I have observed is that the statements in the runAsync 
>>>>>>> have
>>>>>>> no knowledge of the writes that happened in the main thread that spawned
>>>>>>> these async tasks.
>>>>>>>
>>>>>>> My question is around how to run async tasks under the same
>>>>>>> transaction context as the thread that is spawning the async tasks.
>>>>>>>
>>>>>>> Is this something that's doable? Is there a better approach for
>>>>>>> performing async writes ?
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "jOOQ User Group" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to jooq-user+...@googlegroups.com.
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/jooq-user/36d068a7-f26d-4241-82a3-d322c71d38e8n%40googlegroups.com
>>>>>>> <https://groups.google.com/d/msgid/jooq-user/36d068a7-f26d-4241-82a3-d322c71d38e8n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to a topic in
>>>>>> the Google Groups "jOOQ User Group" group.
>>>>>> To unsubscribe from this topic, visit
>>>>>> https://groups.google.com/d/topic/jooq-user/ELuU4s9i1WI/unsubscribe.
>>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>>> jooq-user+...@googlegroups.com.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/jooq-user/CAB4ELO6G3GR7SAyOYFamHk2pBzVta8ggh%3Dce8KOLGfRjc5H8pQ%40mail.gmail.com
>>>>>> <https://groups.google.com/d/msgid/jooq-user/CAB4ELO6G3GR7SAyOYFamHk2pBzVta8ggh%3Dce8KOLGfRjc5H8pQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "jOOQ User Group" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to jooq-user+...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/jooq-user/CAOT1%3D3_YNMxCJbvNwXwGwAt0tapn34HAsP3_03L7NELA27-SEw%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/jooq-user/CAOT1%3D3_YNMxCJbvNwXwGwAt0tapn34HAsP3_03L7NELA27-SEw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
>>>> You received this message because you are subscribed to a topic in the
>>>> Google Groups "jOOQ User Group" group.
>>>> To unsubscribe from this topic, visit
>>>> https://groups.google.com/d/topic/jooq-user/ELuU4s9i1WI/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to
>>>> jooq-user+...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/jooq-user/CAB4ELO4yYvJJFTEF6PgH15n5Ew90G_V6fJEt2%3DzgE2dne0hjXw%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/jooq-user/CAB4ELO4yYvJJFTEF6PgH15n5Ew90G_V6fJEt2%3DzgE2dne0hjXw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "jOOQ User Group" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to jooq-user+...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jooq-user/CAOT1%3D3_Heek4Kc_apUsGWRCgwOoT6JYO%2Bxegb0HySE_5Tk66iQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/jooq-user/CAOT1%3D3_Heek4Kc_apUsGWRCgwOoT6JYO%2Bxegb0HySE_5Tk66iQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jooq-user+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jooq-user/864f1b3e-3813-48dc-b79a-88bdcce5f1f1n%40googlegroups.com
> <https://groups.google.com/d/msgid/jooq-user/864f1b3e-3813-48dc-b79a-88bdcce5f1f1n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jooq-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO5Tiy2ca4shWg4UALEHxSD-am7uUp3%2BNLemyBKnV4e1bQ%40mail.gmail.com.

Reply via email to