Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle: Java + distributed transactions (CORBA OTS + 2PC)
Hello world,
hi Graham (via BCC),
...
> > is there anybody out there who can give me a hint on how to drive an
> > Oracle server from a Java program; I do not need the usual JDBC
> > query/update functionality but the possibility to drive an XA-like
> > two-phase commit (2PC) protocol.
> >
> > I am currently working on my diploma thesis and have developed a
> > skeleton manufacturing execution system MES with Java (JBuilder) and
> > CORBA (VisiBroker). Currently, the resource part is simulated in memory,
> > but it takes part in transaction completion via the OTS-coordinator's
> > prepare(), commit(), commit_one_phase(), and rollback() methods.
...
> resources "simulated in memory"? Do you mean that you aren't actually
> driving any underlying resource, just simulating its participation in
> the transaction? If so, then that shouldn't matter.
I have placed two UML class diagrams on
http://hildner.de/gif/classdi1.gif and
http://hildner.de/gif/classdi2.gif
To summarize the images: The Communicator uses its CORBAInterfaceServer and CORBAInterfaceClient to receive and send CORBA requests, respectively. The IDL only has got two methods: sendRequest(inout String) and sendRequestTA(inout String, org.omg.CosTransactions.Control). This String transfers a function code/method identifier and corresponding parameters, delimited by some character sequence; it is packed by the CORBAInterfaceClient and unpacked by the CORBAInterfaceServer and then dispatched to the corresponding function in the Manager. This avoids building a new IDL when additional functionality is added to the Manager classes.
The application (business logic, GUI) is running "somewhere beyond" the Manager. My task was to add transaction functionality to the yet existing architecture; I did this by introducing the above-mentioned sendRequestTA and by "inserting" the TA_Manager in the inheritance tree. (It works but is still factor 30 -- 40 slower than non-transactional requests ... *sigh*)
The TA_Manager has got two main purposes:
1/2 support transactional bracketing via TA_begin, TA_commit, TA_rollback, etc.; this is mainly a direct mapping to the OTS functions
2/2 simulate a resource (e. g. a database) via RM_get, RM_put, etc.; this currently is a java.util.Hashtable in the TA_ResourceManager and some kind of delta-Hashtable in the TA_Resource's.
The TA_Manager also maps outgoing sendRequest's to a sendRequestTA (via overloading) and propagates transaction context if there has been an application's (i. e. Manager's) TA_begin before. It switches context upon incoming external requests, i. e. it Current.resume's another (or a null) context when encountering another incoming transaction *and* tells the resource (I wish it were Oracle) to now associate all RM_* operations with that new transaction.
I have got a state diagram for that (http://hildner.de/gif/state.gif) but think it will not help too much as one would need sequence diagrams additionally to get a more complete image of the complex interactions that are possible.
The implementation is in Java (JBuilder, VisiBroker).
The resource I use is the TA_Resource class in the diagram. It is an altered version of Inprise's FakeResourceImpl (part of their training material) and inherits from _ResourceImplBase so it implements the OTS resource methods (prepare(), commit(), commit_one_phase(), and rollback()) for joining in the two-phase commit process.
The TA_Resource is instantiated from the TA_ResourceManager. The TA_ResourceManager also register()s a (newly created) resource with the OTS coordinator (when it encounters a new Control and thereby a new transaction (branch)).
I now want to replace the TA_Resource instances (one for each outstanding transaction) with Oracle. Could be I also have to take away or alter the TA_ResourceManager.
> Hopefully, if you phrase your question in terms of the OTS interface, then
> people here will be able to help you without necessarily understanding
> the details of your application.
Hm, so my question is: How do I connect CORBA/OTS and Oracle in a way that Oracle can join in a two-phase commit? And how do it in Java? Any code samples?
> > Important for me is a mechanism that lets a resource alternatingly join
> > several transaction branches, i. e. the resource should work on part of
> > one transaction, then on part of another, and some time later commit the
> > first one and some time later maybe rollback the second one.
>
> Strictly speaking, this is a non-sensical wish:
>
> "Each object supporting the _Resource_ interface is implicitly
> associated with a single top-level transaction." (CosTransactions,
> 10.3.7, from an old version but this part, I'm pretty sure,
> is the same in the latest version.)
With "resource" I meant my "TA_ResourceManager"; it should be able to process sequences like
beginT1 readforT1 beginT2 readforT2 writeforT2 writeforT1 commitT2 commitT1
, i. e. switch (database/service) context between requests (like it should be possible with the Oracle Call Interface for C++?!); these requests carry the transaction context (CosTransactions.Control) explicitly with them. For every Control object/outstanding transaction I have exactly *one* TA_Resource object instantiated which is resolved by the TA_ResourceManager via the Control's hash code.
> > This could
> > be done by connection pooling and JDBC, I think. But it is a problem to
> > get the prepare() functionality for the 2PC which is very important for
> > consistent, distributed updates.
>
> I'm afraid that all of this is greek to me. Resources are associated
> with at most a single transaction, and so I really don't understand your
> requirement here.
I want my TA_Manager to be able to process several transaction branches successively, i. e. be able at any point in time to have *several* transactions to be *outstanding* (I want to commit some time later and just keep on processing another). This could work with JDBC and opening multiple connections (one connection out of a pool of connections for each outstanding transaction); this would be the replacement for the mapping to the TA_Resource objects I currently have.
But the other problem remaining is that I *need* prepare() functionality, i. e. I have to include Oracle in a two-phase commit protocol; a simple JDBC commit does *not* suffice (I want true 2PC). How do I do that?
> > Anyone having any hints, program examples, anything?
Thank you for taking your time!
*ciao*
Klaus (from Stuttgart, Germany)
--
Mit freundlichen Gruessen/Best regards, Klaus Hildner
[http://hildner.de] [mailto:klaus@hildner.de]
Received on Mon Aug 23 1999 - 05:51:55 CDT
![]() |
![]() |