Скачати 14.94 Kb.
Looking at the Code
Building a COMTI Component
Script for Friendship Insurance Demo
In this demonstration we will show how the Microsoft COM Transaction Integrator (COMTI), working in conjunction with the Microsoft Transaction Server and the Microsoft SNA Server, makes true heterogeneous distributed transaction processing not only possible, but easy. If you have attempted to create transactionally integrated application software incorporating IBM mainframes and LAN-based server environments before, you will definitely appreciate the simplicity of the COMTI solution. COMTI makes mainframe applications appear as COM objects with methods that can be invoked via Automation. These objects have transactional properties, like any other COM object participating in Transaction Server packages.
Structure Slide ()
This slide will introduce you to the structure of an application that we have created for this demonstration. It is a 3-tiered health insurance claims processing application with a browser front-end, NT-based server components that use the SQL Server database, and MVS CICS based components that use VSAM and DB2. All of the components that perform database activity work together within the same atomic transaction. Either all of them succeed, or all are backed out, leaving the databases in a consistent state.
The claims form itself is a web page that invokes an active server page. () This active server page creates a COM object called ProcessClaim and invokes a method on it, passing a number of parameters that relate to the claim (policy holder social security number, date of service, health service provider, etc.).
() ProcessClaim in turn creates ClaimKey, which happens to be a COMTI component, and invokes a method to obtain a unique claim identifier. ClaimKey uses VSAM as a persistent store for these ids or “keys”.
() Next, ProcessClaim creates ValidateClaim and invokes a method on it to perform some business rule checking on the claim. If the claim is a valid one, then processing continues, and in this particular demo that’s the path that we will take.
() ProcessClaim then uses the InsertClaimSummary component to insert a summary record in a SQL Server database on NT.
() Finally, ProcessClaim uses another COMTI component, InsertClaim, to insert a detailed claim record in a DB2 database under CICS.
Note that the ValidateClaim operation only involves SQL Server queries and an application of some simple business rules. It does not need to be a part of the atomic transaction. () The Transaction either commits () or aborts (rolls back), based on the success or failure of the individual operations. Also, within this demonstration, we’ve inserted some code to abort the transaction after all operations have been done if the health service provider is given as “Chicago Hope.” This is, of course, for demonstration purposes, but the same action can just as easily be taken based on any application-specific condition.
In demonstrating transactions using COMTI, lets first take a look at the demo application in actual operation. We’ll then take a brief look at some of the application code and then wrap up by creating another COMTI component to add to the package.
Set up the screen for MMC and the Web Page
The Web Page
What we’ve got on the screen now is the FriendShip Insurance claim submission web page on the right and the Microsoft Management Console with COMTI and MTS snapins on the left. Note the two COMTI components with upper case names on the top row.
We’ll first fill out the claim form with some data that will result in a valid claim. () Watch the components animate on the left side of the screen as the operations take place.
That transaction is complete. Now let’s take a look at the SQL Server database () to see what's been inserted into the Claims table…We can see that an entry has been inserted for claim # xxxx.
Now we'll use the Chicago Hope provider to cause the next transaction to abort. () We’ll switch to the Transaction Statistics view in the MTS MMC snapin in order to see this. You'll notice that we've already logged a few committed transactions recorded from a previous session as well as our most recent claim.
OK, now let's submit this claim using Chicago Hope as our provider. () The components run again, and the mainframe logs activity, but this time….the transaction is backed out. We can see that one aborted transaction now appears in the Statistics.
Lets submit one more good one, () and then we'll have a look at the databases.
Now we'll run the SQL Server query again (). Here we can see that the entries on either side of the aborted transaction are present, but the one for Chicago Hope is not there. It has been backed out.
Finally, we'll do the same thing on the mainframe side with DB2 ()…… Again we see evidence of the two committed transactions, but the aborted one is absent, as expected.
(Switch to VB showing ProcessClaim, showing InsertClaim)
Now that you've seen the application run, we'll take a quick look at a typical application code fragment written in VB. () Here we see the function InsertClaim within the component ProcessClaim. Here is the line of code that creates the object, and here is the line that invokes the InsertClaim method, passing the claim number, date of service, etc. The important thing to note is that there is absolutely nothing COMTI-specific about these lines of code -- nothing that gives away the fact that a mainframe application will be executed behind the scenes. This could be an invocation of ANY automation server.
(Switch to end of mainline in ProcessClaim)
And here is the logic at the end of ProcessClaim (the mainline code of the application) that either commits or aborts the transaction. The ErrorHandler is executed whenever any part of the logic detects an anomaly (for example, an ABEND on the host or a SQL Server error code, OR the use of Chicago Hope as a health service provider). Here we simply do a "SetAbort" on the context object. Otherwise, we do a SetComplete. Simple as that. COMTI and the Distributed Transaction Coordinator within the Transaction Server ensure that the abort path of the 2 Phase Commit protocol is properly executed "behind the scenes".
(Switch to Component Builder but keep MMC up also)
As the last step of the COMTI Tranactional demonstration, we'll build a missing COMTI component. The demo application also has the ability to log a "Rejected Claim" using DB2 on the mainframe. Rejected claims are not aborted transactions. They are transactions that fail to pass the business rules for a valid claim. For example, a claim that exceeds an allowable dollar amount is rejected.
We already have the COBOL program that inserts rejected claim records into a DB2 table. Now we simply want to build a component that will have the proper interface for this COBOL application and will serve as its proxy in the NT world. So the first thing that we'll do is to bring up the COMTI Component Builder ().
We'll create a New () Component with a Prog ID = CLAIMSRV3.INSERTREJECTEDCLAIM.1" and set its transactional property to “requires a transaction.” We'll then () Import our COBOL application source code, locate its COMMAREA (which defines its interface), and Add () it as a Method in our new Component. We’ll select the COBOL variable RVAL as our return value for the method, and then we're then done with the COBOL import process. COMTI has parsed the COBOL and determined what the equivalent Automation interface is.
We're done, and we can now save the type library that Component Builder has created. We'll save it as Rejected.tlb.
The final step is to install the new component into the Transaction Server package with all of the others. We do this by a simple drag and drop process. It is now ready to be used by our VB application, just like its counterpart "INSERTCLAIM".
|Project title (title of idea) Author Surname||The title of the article|
|Title of the Abstract||Title author Name|
|Abbreviated Journal Title||Course Title: Theory and History of English|
|Требования к оформлению материалов І международной конференции «Человек. Компьютер. Коммуникация» (используйте стиль Main Title) Имя Фамилия (используйте стиль Author) Кафедра прикладной лингвистики, Национальный университет «Львовская политехника»|
Требования к оформлению материалов І международной конференции «Человек. Компьютер. Коммуникация» (используйте стиль Main Title)
|Title of the paper if longer than 1 line it views like it|
|The title: Times New Roman, 12, bold, Uppercase and centered||Your Paper's Title Starts Here: Please Center use Helvetica (Arial) 14|