【正文】
LINES*output_par_num*50, service_name,GPARM32_0,temp_buf,LABELDBCHANGE,CONNECT0)。 每調(diào)用一次,向指定域中寫入一個元素,沒有下標(biāo)控制,順序?qū)懭搿P枰⒁獾牡胤剑阂驗(yàn)镕add32()/Fchg32()會往buffer中增加字段,所以有可能原來申請的buffer空間不夠。len = (FLDLEN32)(FIRST_OCCS32 * output_par_num * 50)。/*,define FIRST_OCCS32 100*/transOUT=(FBFR32 *)tpalloc(FMLTYPE32,NULL,len)。transOUT=add_value32(transIN,transOUT,ONCE_ADD_LINES*output_par_num*50, spubGetId,GPARM32_2,oNewId,dbchange,CONNECT0)。/*define ONCE_ADD_LINES 10 ,作為增加緩沖區(qū)的增量*/此外,在一些公共查詢函數(shù)中,還限制了緩沖區(qū)的域的最大數(shù)量為50,也就是限制了查詢表記錄的列數(shù)。例如:public ArrayList sPubSelect(String colNum, String sqlStr)4. TUXEDO應(yīng)用程序開發(fā)TUXEDO系統(tǒng)屏蔽了硬件、網(wǎng)絡(luò)、數(shù)據(jù)庫和操作系統(tǒng)的復(fù)雜性,提供了一套簡單統(tǒng)一的編程接口,使程序員可以把精力集中在業(yè)務(wù)邏輯的實(shí)現(xiàn)上,而不必為數(shù)據(jù)庫、操作系統(tǒng)和網(wǎng)絡(luò)通信協(xié)議的復(fù)雜性、異構(gòu)性和可靠性擔(dān)憂。TUXEDO提供的一套C語言編程接口,中文名字可以叫做“應(yīng)用程序事務(wù)監(jiān)控接口” ,方便了開發(fā)客戶程序和服務(wù)程序,即ATMI。Tuxedo通過ATMI,實(shí)質(zhì)上是對IPC資源本身API的再次封裝,從而提供了更高一層的API以建立分布式應(yīng)用組件,包括服務(wù)程序、客戶程序和事務(wù)管理器等。這些組件在執(zhí)行時以消息相互通訊,由Tuxedo的內(nèi)部服務(wù)機(jī)制統(tǒng)一管理。這些服務(wù)機(jī)制實(shí)現(xiàn)了復(fù)雜的分布式事務(wù)控制和廣泛的分布式應(yīng)用管理。而在通信過程中,所有的過程都是通過類型緩沖區(qū)來完成的。這實(shí)際上就是對消息隊(duì)列的操作,從而獲得相應(yīng)的IPC資源ATMI已經(jīng)超越了字面上“監(jiān)控接口”的含義,它是一種高度封裝的Tuxedo 應(yīng)用編程接口。它是一個真正的事務(wù)處理和消息傳遞中間件??蛻襞c服務(wù)之間的通訊方式有很多種,如同步方式、異步方式、事件通知、隊(duì)列方式。隊(duì)列方式用于可靠的數(shù)據(jù)傳遞,在省際之間的數(shù)據(jù)傳輸系統(tǒng)中可以使用隊(duì)列方式,在我們的系統(tǒng)中,應(yīng)用的性質(zhì)是實(shí)時的在線業(yè)務(wù)處理,使用同步方式(tpcall)即可。 常用的ATMI(目前不全,請參閱相關(guān)文檔) 下面是TUXEDO自身的API函數(shù)列表,也是TUXEDO的ATMI具體函數(shù):Table Using the ATMI Functions For a task related to . . .Use this C function . . .Or this COBOL function . . .To . . .Client membershiptpchkauth(3c)TPCHKAUTH(3cbl)Check whether authentication is requiredtpinit(3c)TPINITIALIZE(3cbl)Have a client join an applicationtpterm(3c)TPTERM(3cbl)Have a client leave an applicationBuffer managementtpalloc(3c)N/ACreate a message buffertprealloc(3c)N/AResize a message buffertpfree(3c)N/AFree a message buffertptypes(3c)N/AGet a message type and subtypeMessage prioritytpgprio(3c)TPGPRIO(3cbl)Get the priority of the last requesttpsprio(3c)TPSPRIO(3cbl)Set the priority of the next requestRequest/response municationstpcall(3c)TPCALL(3cbl)Initiate a synchronous request/response to a servicetpacall(3c)TPACALL(3cbl)Initiate an asynchronous request (fanout)tpgetrply(3c)TPGETRPLY(3cbl)Receive an asynchronous responsetpcancel(3c)TPCANCEL(3cbl)Cancel an asynchronous requestConversational municationstpconnect(3c)TPCONNECT(3cbl)Begin a conversation with a servicetpdiscon(3c)TPDISCON(3cbl)Abnormally terminate a conversationtpsend(3c)TPSEND(3cbl)Send a message in a conversationtprecv(3c)TPRECV(3cbl)Receive a message in a conversationMessage queuing municationstpenqueue(3c)TPENQUEUE(3cbl)Enqueue a message to a message queuetpdequeue(3c)TPDEQUEUE(3cbl)Dequeue a message from a message queuePublishandsubscribe municationstpnotify(3c)TPNOTIFY(3cbl)Send an unsolicited message to a clienttpbroadcast(3c)TPBROADCAST(3cbl)Send messages to several clientstpsetunsol(3c)TPSETUNSOL(3cbl)Set unsolicited message callbacktpchkunsol(3c)TPCHKUNSOL(3cbl)Check the arrival of unsolicited messagesN/ATPGETUNSOL(3cbl)Get an unsolicited messagetppost(3c)TPPOST(3cbl)Post an event messagetpsubscribe(3c)TPSUBSCRIBE(3cbl)Subscribe to event messagestpunsubscribe(3c)TPUNSUBSCRIBE(3cbl)Unsubscribe to event messagesTransaction management (see note at end of table)tpbegin(3c)TPBEGIN(3cbl)Begin a transactiontpmit(3c)TPCOMMIT(3cbl)Commit the current transactiontpabort(3c)TPABORT(3cbl)Roll back the current transactiontpgetlev(3c)TPGETLEV(3cbl)Check whether in transaction modetpsuspend(3c)TPSUSPEND(3cbl)Suspend the current transactiontpresume(3c)TPRESUME(3cbl)Resume a transactionService entry and returntpsvrinit(3c)TPSVRINIT(3cbl)Initialize a servertpsvrdone(3c)TPSVRDONE(3cbl)Terminate a servertpservice(3c)N/APrototype for a service entry pointN/ATPSVCSTART(3cbl)Get service informationtpreturn(3c)TPRETURN(3cbl)End a service functiontpforward(3c)TPFORWAR(3cbl)Forward requestDynamic advertisementtpadvertise(3c)TPADVERTISE(3cbl)Advertise a service nametpunadvertise(3c)TPUNADVERTISE(3cbl)Unadvertise a service nameResource managementtpopen(3c)TPOPEN(3cbl)Open a resource managertpclose(3c)TPCLOSE(3cbl)Close a resource manager BEA Tuxedo系統(tǒng)提供多種通信模式⑴. 同步Request/Response模式;⑵. 異步Request/Response模式;⑶. 嵌套調(diào)用;⑷. 調(diào)用轉(zhuǎn)發(fā);⑸. 會話通信;⑹. 主動消息通告;⑺. 基于事件的通信;⑻. 基于隊(duì)列的通信;⑼. 使用事務(wù)。要進(jìn)行同步調(diào)用,Bea Tuxedo客戶程序使用ATMI函數(shù)tpcall()把一個請求送到服務(wù)程序。客戶程序要等到服務(wù)程序做出響應(yīng)后才處理后面的工作,也就是說,它在收到服務(wù)程序的響應(yīng)之前一直處于阻塞狀態(tài)。OLTP系統(tǒng)最大的特點(diǎn)就是實(shí)時性,而同步調(diào)用可以很好地保證交易的實(shí)時性,因此是TUXEDO聯(lián)機(jī)交易系統(tǒng)中使用頻率最高的一種消息范例。 ATMI消息處理流程圖41 ATMI消息處理流程A client uses an ATMI function to request a service by name. A naming facility is used to checkthe MIB to determine whether the specified service is currently available.The BEA Tuxedo system uses datadependent routing, which is an automatic routing option tomap messages that meet specific criteria (message value) to a specific server. If messages usedatadependent routing, the system uses the data in the buffer for the routing algorithm. Thisalgorithm provides a method of selecting a group of servers that can process the service request.To avoid burdening a few servers with many requests while leaving other servers that advertisethe same services idle, the BEA Tuxedo system maintains a set of metrics in the MIB that help itdistribute service requests evenly across all servers. This practice is called load balancing.A local service request may be prepared for a selected server and enqueued on that server’s queuewith a predefined priority. This practice is called service prioritization. Once the service requestis on the server, the runtime system retrieves the message in priority order. The message isdispatched to the appropriate service and processed. Then the results are returned to the clientqueue.BEA Tuxedo systemprovided software offers features that an application can automatically androutinely use during message processing. These features include data encoding and decoding,data pression and depression, transactional context setting, and security processing, toname a few. In addition, the BEA Tuxedo system software invokes application business logic bydispatching a service function and passing it to the appropriately preprocessed buffer.The service routine is executed and returns a reply (also a typed buffer). The runtime systemprepares the reply for the client by encoding the message automatically: it packages the data insuch a way that it can be transmitted between machines on which different types of byte orderingare used, allowing data to cross network and platform boundaries. The system then s