wsadmin 스크립트를 사용하여 활성 및 준비된 트랜잭션 관리
wsadmin 스크립트를 사용하여 관리자 조치가 필요할 수 있는 활성 및 준비된 트랜잭션을 관리할 수 있습니다.
시작하기 전에
이 태스크 정보
일반적으로는
개입 없이 자동으로 트랜잭션이 실행
및 완료(커미트 또는 롤백)되어야
합니다. 그러나 경우에 따라 트랜잭션을
수동으로 해석해야 할 수도 있습니다. 예를
들어, 필수 시간 범위 내에서 다시 사용할 수 없게
될 자원 관리자를 계속 폴링하는 트랜잭션을 롤백할 수
있습니다.
일반적으로는 트랜잭션을 완료하기
위해 최선의 노력을 다합니다. 그러나 RRS(Resource Recovery
Services) 및 기본 컨텍스트 완료로 인해 트랜잭션을 완료하지 못할
수 있습니다. 이 경우 트랜잭션이 rollback_only로
표시되어 다음 사용 가능한 창에서 롤백됩니다. 다른 상황에서는
트랜잭션을 수동으로 완료해야 할 수 있습니다. 예를
들어, 필수 시간 범위 내에서 다시 사용할 수 없게
될 자원 관리자를 계속 폴링하는 트랜잭션을 완료할 수
있습니다.
참고: 애플리케이션 서버에서
트랜잭션을 완료하도록 선택하는 경우에는 해당 서버에 대한
트랜잭션 서비스 로그에서 완료된 것으로 기록되므로 서버
시작 시 복구될 수 없습니다. 트랜잭션을 완료하는
경우 영향을 받은 자원 관리자에 대한 인다우트
트랜잭션을 정리해야 합니다.
TransactionService 및 Transaction MBean에 대한 자세한 정보는 API(Application Programming Interface) 문서를 참조하십시오.
프로시저
예
다음 스크립트는 수동 트랜잭션 작업을 위해 TransactionService 및 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