[ 
https://issues.apache.org/jira/browse/IGNITE-4887?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16019954#comment-16019954
 ] 

Igor Gorkov commented on IGNITE-4887:
-------------------------------------

Yakov Zhdanov, well, every sinlge situation that I thought about is rely on 
end() and resume() :) Execpt fo trivial ones. The first thing that comes to 
mind it's situations, when distributed transaction coordinator is elsewhere. I 
don't want to bother you much buisness details, but we have system, that 
operates just this way. So, Ignite in this case is one of resources. When start 
message is received local manager should initiate ignite transaction before 
answering to coordinator (maybe combine start and prepare messages - doesn't 
matter in this case). And, while awaiting for commit message, it will be handy 
to free thread in wich buisness logic was done. Let's clarify on example from 
ignite documentation:

{code:title=example.java|borderStyle=solid}
// Start JTA transaction.
jtaTx.begin();

try {
    // Do some cache operations.
    cache.put("key1", 1);
    cache.put("key2", 2);
    CAN'T COMMIT HERE, NEEDS TO WAIT FOR COMMIT MESSAGE
    // Commit the transaction.
    jtaTx.commit();
}
{code}

So, in my case things going this way:
# Local manager receives request to start transaction, it's creates Transaction 
object T, and invokes some buisness logic, wich is some cache operations
# For this operations Ignite creates IgniteTransaction, wraps it in XAResource 
and enslits it in T. Then do the cache operations
# At this point local manager waits for coordinator directions, and I wish to 
call end() method, while coordinator is talking to the rest of the systems. So 
we can free that thread for another operations
# After receiving coordinator instructions, manager simply calls prepare or 
commit in his own thread

I think that's it

> Support for starting transaction in another thread
> --------------------------------------------------
>
>                 Key: IGNITE-4887
>                 URL: https://issues.apache.org/jira/browse/IGNITE-4887
>             Project: Ignite
>          Issue Type: Improvement
>          Components: general
>    Affects Versions: 1.9
>            Reporter: Alexey Kuznetsov
>            Assignee: Alexey Kuznetsov
>
> Consider the following pseudo-code:
> {code:xml}
>         IgniteTransactions transactions = ignite1.transactions();
>         Transaction tx = startTransaction(transactions);
>         cache.put("key1", 1);
>         tx.stop();
> {code}
> And in another thread:
> {code:xml}
>                 transactions.txStart(tx);
>                 cache.put("key3", 3);
>                 cache.remove("key2");
>                 tx.commit();
> {code}
> The Api should be implemented , that let you continue transaction in another 
> thread.
> method stop() should mark the transaction as unavailable for further commit.
> method txStart() should resume the transaction. 
> reason behind the proposal :
> Consider the next scenario:
> we begin transaction, doing some changes and start async future that will be 
> able to introduce futher changes into transaction and commit it in the end.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to