[Registry-dev] Transaction support in the embedded registry
Deepal Jayasinghe
deepal at wso2.com
Tue Apr 1 22:03:17 PDT 2008
Hi Chathura ,
>
> I am implementing the transaction support in the embedded registry
> layer. I have introduced below four methods to the Registry API to
> handle transactions. These methods can be used by client application
> in a similar way to JDBC connection transactions.
>
> registry.beginTransaction();
>
> registry.commit();
>
> registry.rollback();
>
> registry.endTransaction();
Rather than adding these methods to registry API cant we come up with a
new class (say TransactionManager) and add those four methods there. And
we can create the TransactionManager by giving the registry instance or
whatever needed.
>
> When beginTransaction() is called, a database connection is obtained
> and stored in a thread local variable. Then all other database related
> registry components use that connection by calling:
Well this a problem when it comes to APP, because in the case of APP
storing in the thread local will not provide what we want. Because when
we use APP for each and every request it creates a new thread so what we
store in last request can not access from the new request.
I think we need to think this in bit higher level , something like RM
session. Where when a user start a transaction we give him a session
key (and store the connection in a table alone with the key) and he is
supposed to send the key back when he call the second call in the same
transaction. If we do so we can handle this in APP without having any
problem.
>
> Connection conn = Transaction.getConnection();
>
> When a transaction is started, connections are not commited unless
> registry.commit() is called. Therefore, client application can perform
> sequence of operations in a single transaction by listing them within
> registry.beginTransaction() and registry.commit(). Once the
> transaction is complete client applications should call
> registry.endTransaction(), so that the connection is closed and the
> thread local variable is cleared.
What happen if the client does not call endTransaction ?
Someone can attack registry by just creating transactions and not
closing them , I think we have to agree what we are going to do on this.
Thank you!
Deepal
More information about the Registry-dev
mailing list