Date post: | 03-Jun-2018 |
Category: |
Documents |
Upload: | srinivasa-helavar |
View: | 219 times |
Download: | 0 times |
of 33
8/12/2019 09-TRAN
1/33
2007 BEA Systems, Inc. 427
Managing Transactions
At the end of this module you will be able to:
Configure transactions using the console
Monitor transactions using the console
Module 9
Managing Transactions-1
8/12/2019 09-TRAN
2/33
2007 BEA Systems, Inc. 428
1. Configuring and Monitoring Transactions Configuring Transactions Monitoring Transactions The Transaction Log
Road Map
Managing Transactions-2
8/12/2019 09-TRAN
3/33
2007 BEA Systems, Inc. 429
What Is a Transaction?
A transaction is a mechanism to handle groups ofoperations as though they were one.
Either all operations in a transaction occur or none atall.
Operations involved in a transaction might rely onmultiple servers and databases.
Managing Transactions-3
8/12/2019 09-TRAN
4/33
2007 BEA Systems, Inc. 430
ACID Properties of a Transaction
A transaction is formally defined by the set of propertiesknown by the acronym ACID.
Atomicity : A transaction is done or undone completely. In theevent of a failure, all operations and procedures are undone,and all data rolls back to its previous state.
Consistency : A transaction transforms a system from oneconsistent state to another consistent state.
Isolation : Each transaction occurs independently of othertransactions occurring at the same time.
Durability : Completed transactions remain permanent, evenduring system failure.
Managing Transactions-4
8/12/2019 09-TRAN
5/33
2007 BEA Systems, Inc. 431
Transaction Management
Application 1
MessagingServer
SQL serverDatabase
(Resource)
PointBaseDatabase
(Resource)
Manages
Transactions
End-to-EndTransaction Manager
WebLogicServer
Resource Manager
Resource Manager
Resource Manager
JTA
Managing Transactions-5
8/12/2019 09-TRAN
6/33
2007 BEA Systems, Inc. 432
Transferring Without Transactions
Successful transfer (A)
Unsuccessful transfer (accounts are left in an inconsistent state)(B)
$1000+$100$1100
$500-$100
$400
2) Deposit: $100
1) Withdraw: $100
Transfer: $100From: Acct 1To: Acct 2
ATM Bank
Account 1
Account 2
$1000
$500-$100
$4001) Withdraw: $100
Transfer: $100From: Acct 1To: Acct 2
ATM Bank
Account 1
Account 2FailedDeposit
A
B
Managing Transactions-6
8/12/2019 09-TRAN
7/33 2007 BEA Systems, Inc. 433
Successful Transfer with Transactions
Changes within a transaction are buffered. (A)
If a transfer is successful, changes are committed (made permanent). (B)
Transfer: $100From: Acct 1To: Acct 2
ATM Bank
Transaction Started by Bank $500-$100
$4001) Withdraw: $100 Account 1
Account 2$1000+$100$1100
2) Deposit: $100
Transaction Started by Bank
$1100
$400Commit
TransferSuccessful
ATM Bank Account 1
Account 2Commit
A
B
Managing Transactions-7
8/12/2019 09-TRAN
8/33 2007 BEA Systems, Inc. 434
Changes within a transaction are buffered. (A)
If a problem occurs, the transaction is rolled back to the previousconsistent state. (B)
Transfer: $100From: Acct 1To: Acct 2
ATM Bank
Transaction Started by Bank
$1000
$500
-$100$400
1) Withdraw: $100 Account 1
Account 2FailedDeposit
Transaction Started by Bank
$1000
$500Rollback
Errormessage
ATM Bank Account 1
Account 2Rollback
Unsuccessful Transfer with Transactions
A
B
Managing Transactions-8
8/12/2019 09-TRAN
9/33 2007 BEA Systems, Inc. 435
Types of Transactions
A local transaction deals with a single resourcemanager. They use the non-Extended Architecture(non-XA) interface between WebLogic Server andresource managers.
A distributed transaction coordinates or spans multipleresource managers.Global transactions can deal with multiple resourcemanagers. They use the Extended Architecture (XA)interface between WebLogic Server and resourcemanagers. You need to create non-XA or XA resources for local
transactions. However, for global transactions, you only needto create XA resources.
Managing Transactions-9
8/12/2019 09-TRAN
10/33 2007 BEA Systems, Inc. 436
The Two-Phase Commit Protocol
The Two-Phase Commit (2PC) protocol uses two stepsto commit changes within a distributed transaction. Phase 1 asks RMs to prepare to make the changes Phase 2 asks RMs to commit and make the changes
permanent, or to roll back the entire transactionA global transaction ID (XID ) is used to track allchanges associated with a distributed transaction.
Managing Transactions-10
8/12/2019 09-TRAN
11/33 2007 BEA Systems, Inc. 437
Extended Architecture Protocol
The Extended Architecture (XA) protocol: Is the interface used between WLS and RMs Implements the 2PC protocol Allows programs to control RMs that are involved in
distributed transactions
Client TransactionManager
RM1
RM2
XA
XA
Managing Transactions-11
8/12/2019 09-TRAN
12/33 2007 BEA Systems, Inc. 438
A transaction manager coordinates multiple resource managers.
The 2PC protocol is used to coordinate the transaction.
The XA protocol implements 2PC.
Transaction and Resource Managers
Transaction Context started by Transaction Manager
TransactionManager
ResourceManager
ResourceManager
ResourceManager
Database
Printer
Another App
Application
XA
XA
XA
Managing Transactions-12
8/12/2019 09-TRAN
13/33 2007 BEA Systems, Inc. 439
Successful Two-Phase Commit
Application
TLOG
TransactionManager
ResourceManager
ResourceManager
ResourceManager
Database
Printer
Another App
Applicationpre-commit
ready
TransactionManager
ResourceManager
ResourceManager
ResourceManager
Database
Printer
Another App
commit
committed
Phase 1Phase 2
TLOG
Managing Transactions-13
8/12/2019 09-TRAN
14/33 2007 BEA Systems, Inc. 440
Unsuccessful Two-Phase Commit
pre-commit
abort
notready
ready
prepare/abort
ready/committed
notready
rolledback
ResourceManagerResourceManager
ResourceManager
Database
Printer
Another App
ResourceManager
ResourceManagerResourceManager
Database
Printer Another
App
Application
TLOG
TransactionManager
Application
TransactionManager
Phase 1Phase 2
TLOG
Managing Transactions-14
8/12/2019 09-TRAN
15/33 2007 BEA Systems, Inc. 441
Java Transaction API (JTA)
WLS uses JTA to implement and manage transactions.WLS JTA provides the following support: It creates a unique transaction identifier ( XID ).
It supports an optional transaction name. It tracks objects involved in transactions. It notifies databases of transactions. It orchestrates 2PC using XA.
It executes rollbacks. It executes automatic recovery procedures when failure. It manages time-outs.
Managing Transactions-15
8/12/2019 09-TRAN
16/33 2007 BEA Systems, Inc. 442
Configuring Transactions
2
1
Managing Transactions-16
8/12/2019 09-TRAN
17/33 2007 BEA Systems, Inc. 443
Each server has a transaction log that storesinformation about committed transactions coordinated by the server that may not have been completed. WebLogic Server uses the transaction log when recovering
from system crashes or network failures.You cannot directly view the transaction log as therecords are in a binary format.
T-log files must be migrated if migrating to a newmachine.
Configuring the Transaction Log
Managing Transactions-17
8/12/2019 09-TRAN
18/33 2007 BEA Systems, Inc. 444
Configuring the Transaction Log
.tlog files are stored in the default persistent storefor the server.
Directory represents the path name to the file systemdirectory where the file store maintains its data files.
Managing Transactions-18
8/12/2019 09-TRAN
19/33 2007 BEA Systems, Inc. 445
JTA Configuration Options
Field Description
Timeout Seconds Specifies the time in which a transaction willtimeout, if uncommitted
Abandon Timeout Seconds Specifies the maximum time that a transactionmanager will persist in attempting to complete atransaction during the second phase of thetransaction
Before Completion IterationLimit
Specifies the maximum number of cycles thatthe transaction manager will perform thebeforeCompletion() synchronizationcallback for this WebLogic Server domain
Max Transactions Specifies the maximum number of
simultaneous in-progress transactions allowedon a server in the domain
Max Unique Name Statistics Specifies the maximum number of uniquetransaction names for which statistics will bemaintained
Managing Transactions-19
8/12/2019 09-TRAN
20/33 2007 BEA Systems, Inc. 446
JTA Configuration Options
Field Description
Checkpoint Interval Seconds Specifies the interval at which the transactionmanager creates a new transaction log file andchecks all old transaction log files to see if theyare ready to be deleted
Forget Heuristics Specifies whether the transaction manager willautomatically perform an XAResource forget() operation for heuristic transaction completions
Unregister Resource GracePeriod
Specifies the grace period, in seconds, that thetransaction manager waits for transactionsinvolving the resource to complete beforeunregistering a resource
Security Interoperability Mode Specifies the security mode to use for XA calls ininter-domain transactions
Managing Transactions-20
8/12/2019 09-TRAN
21/33 2007 BEA Systems, Inc. 447
Creating XA Resources
Managing Transactions-21
8/12/2019 09-TRAN
22/33
2007 BEA Systems, Inc. 448
Creating Non- XA Resources
Managing Transactions-22
8/12/2019 09-TRAN
23/33
2007 BEA Systems, Inc. 449
Creating Non -XA Resources
Managing Transactions-23
8/12/2019 09-TRAN
24/33
2007 BEA Systems, Inc. 450
Logging Last Resource
You can configure a JDBC data source to enable the LoggingLast Resource (LLR) transaction optimization, which: Enables one non-XA resource to participate in a global transaction Has improved performance and the same ACID guarantee as XA
The LLR optimization improves performance by: Removing the need for an XA JDBC driver to connect to the database.XA JDBC drivers are typically inefficient compared to non-XA JDBCdrivers
Reducing the number of processing steps to complete the transaction,which also reduces network traffic and I/O
Removing the need for XA processing at the database level (if thedatabase is the one non-XA resource)
Managing Transactions-24
8/12/2019 09-TRAN
25/33
2007 BEA Systems, Inc. 451
Transacted Messaging
A JMS client can use JTA to participate in a distributedtransaction.
Alternatively, a JMS client can demarcate transactionslocal to the JMS Session through a transacted session.
Participation in a transaction is optional.
All messages arriveat destination
Begin Transact ion 1
C o m m i t
Begin Transact ion 2
C o m m i t
Producer Consumer
Messages are removedfrom destination
Managing Transactions-25
8/12/2019 09-TRAN
26/33
2007 BEA Systems, Inc. 452
Inter-Domain Transactions
WebLogic Server supports global transactions acrossdomains on different versions of WebLogic Server.
To enable WebLogic Server domains for inter-domaintransactions:
Enable trust between the different domains Ensure that each contributing XA resource has a unique
name Ensure that only one of the participating resources in the
distributed transaction can emulate the two-phase commitor XA protocol
Managing Transactions-26
8/12/2019 09-TRAN
27/33
2007 BEA Systems, Inc. 453
Enable Trust Among Different Domains
Managing Transactions-27
8/12/2019 09-TRAN
28/33
8/12/2019 09-TRAN
29/33
2007 BEA Systems, Inc. 455
Monitoring Transactions by Resource
For a particular resource, the console providesmonitoring of transactional outcomes: Number of transactions attempted Number of commits/rollbacks
Number of heuristic outcomes
Managing Transactions-29
8/12/2019 09-TRAN
30/33
2007 BEA Systems, Inc. 456
Monitoring Transactions
Managing Transactions-30
8/12/2019 09-TRAN
31/33
2007 BEA Systems, Inc. 457
Section Review
Configuring transactions
Monitoring transactions
Logging transactions
In this section we discussed:
Managing Transactions-31
8/12/2019 09-TRAN
32/33
2007 BEA Systems, Inc. 458
Exercise
In these labs you will work with monitoring DataSources.
Ask the instructor for any clarification.The instructor willdetermine the stop time.
Data Sources and Transactions
Lab Exercise
Managing Transactions-32
8/12/2019 09-TRAN
33/33
Module Review
Configuring transactions using the console
Monitoring transactions in WebLogic Server
In this module we discussed: