wsadmin スクリプトを使用したアクティブ・トランザクションおよび準備済みトランザクションの管理

wsadmin スクリプトを使用して、管理者による処置が必要になる場合があるアクティブ・トランザクションと準備済みトランザクションを管理します。

始める前に

このタスクを開始する前に、wsadmin スクリプト・クライアントが稼働している必要があります。

このタスクについて

[AIX Solaris HP-UX Linux Windows][IBM i]通常の環境では、トランザクションは自動的に実行され、自動的に完了 (コミットまたはロールバック) するので、特に介入する必要はありません。 ただし、環境によっては、トランザクションを手動で解決する必要があります。 例えば、必要な時間フレーム内に再び使用可能にならないことが明らかなリソース・マネージャーをポーリングしてトランザクションが動作を停止した場合は、トランザクションをロールバックします。

[z/OS]通常の環境では、トランザクションはあらゆる手段によって終了されます。 ただし、リソース・リカバリー・サービス (RRS) およびネイティブ・コンテキスト・フィニッシングにより、トランザクションを終了できない場合があります。 この場合、次の使用可能なウィンドウでロールバックされるように、トランザクションには rollback_only のマークが付加されます。 このほかの場合、トランザクションを手動で終了する必要がある場合があります。 例えば、必要な時間フレーム内に再び使用可能にならないことが明らかなリソース・マネージャーをポーリングしてトランザクションが動作を停止した場合は、トランザクションを終了します。

注: アプリケーション・サーバー上でトランザクションを完了すると、そのサーバーのトランザクション・サービス・ログに完了と記録されるため、サーバーの始動時にはリカバリーすることができません。 トランザクションを完了する際には、影響のあるリソース・マネージャー上の未確定トランザクションはすべてクリーンアップするようにしてください。

TransactionService MBean および Transaction MBean について詳しくは、アプリケーション・プログラミング・インターフェース (API) の文書を参照してください。

手順

以下のスクリプトは、TransactionService MBean と Transaction MBean の使用方法を示して、手動のトランザクションで処理する例です。このスクリプトは、アプリケーション・サーバーに対してのみ実行し、デプロイメント・マネージャーまたはノード・エージェントに対しては実行しないでください。

Jacl スクリプトの例:
# get the TransactionService MBean
set servicembean [$AdminControl queryNames type=TransactionService,*]

# get the Transaction MBean
set mbean [$AdminControl queryNames type=Transaction,*]

set input 0
while {$input >= 0} {
        # invoke the listManualTransactions method
        set tranManualList [$AdminControl invoke $servicembean listManualTransactions]

        if {[llength $tranManualList] > 0} {
                puts "----Manual Transaction details---------------"
                set index 0
                foreach tran $tranManualList {
                        puts "   Index= $index tran= $tran"
                        incr index
                }
                puts "----End of Manual Transactions ---------------"
                puts "Select index of transaction to commit/rollback:"
                set input [gets stdin]
                if {$input < 0} {
                        puts "No index selected, exiting."
                } else {
                        set tran [lindex $tranManualList $input]
                        set commaPos [expr [string first "," $tran ]-1]
                        set localTID [string range $tran 0 $commaPos]
                        puts "Enter c to commit or r to rollback Transaction $localTID"
                        set input [gets stdin]
                        if {$input=="c"} {
                                puts "Committing transaction=$localTID"
                                $AdminControl invoke $mbean commit $localTID
                        }
                        if {$input=="r"} {
                                puts "Rolling back transaction=$localTID"
                                $AdminControl invoke $mbean rollback $localTID
                        }
                }
        } else {
                puts "No Manual transactions found, exiting"
                set input -1
        }
        puts " "

}
Jython スクリプトの例:
import sys
def wsadminToList(inStr):
        outList=[]
        if (len(inStr)>0 and inStr[0]=='[' and inStr[-1]==']'):
                tmpList = inStr[1:-1].split(" ")
        else:
                tmpList = inStr.split("¥n")  #splits for Windows or Linux
        for item in tmpList:
                item = item.rstrip();        #removes any Windows "¥r"
                if (len(item)>0):
                        outList.append(item)
        return outList
#endDef

servicembean = AdminControl.queryNames("type=TransactionService,*" )
mbean = AdminControl.queryNames("type=Transaction,*" )
input = 0

while (input >= 0):
        tranList = wsadminToList(AdminControl.invoke(servicembean, "listManualTransactions" ))

        tranLength = len(tranList) 
        if (tranLength > 0):
                print "----Manual Transaction details---------------"
                index = 0
                for tran in tranList:
                        print "   Index=" , index , " tran=" , tran
                        index = index+1
                #endFor 
                print "----End of Manual Transactions ---------------"
                print "Select index of transaction to commit/rollback:"
                input = sys.stdin.readline().strip()
                if (input == ""):
                        print "No index selected, exiting."
                        input = -1
                else:
                        tran = tranList[int(input)]
                        commaPos = (tran.find(",") -1)
                        localTID = tran[0:commaPos+1]
                        print "Enter c to commit or r to rollback transaction ", localTID
                        input = sys.stdin.readline().strip()
                        if (input == "c"):
                                print "Committing transaction=", localTID
                                AdminControl.invoke(mbean, "commit", localTID )
                        #endIf
                        elif (input == "r"):
                                print "Rolling back transaction=", localTID
                                AdminControl.invoke(mbean, "rollback", localTID )
                        #endIf
                        else:
                                input = -1
                        #endelse
                #endElse
        else:
                print "No transactions found, exiting"
                input = -1
        #endElse
        print " "

#endWhile

トピックのタイプを示すアイコン タスク・トピック



タイム・スタンプ・アイコン 最終更新: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tjta_manage_scripts
ファイル名:tjta_manage_scripts.html