|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.exolab.core.service.Service | +--org.exolab.core.service.BasicService | +--org.exolab.jms.messagemgr.ResourceManager
The resource manager provides XA support for the JMS Server.
The resource manager is responsible for managing the various transaction identifiers and managing the association between transaction ids and connections.
The resource manager will store the global XID's and their state in the database for recovery purposes.
Messages that arrive, and are associated with an XID are not processed
through the MessageMgr
. Instead they are routed to this resource
managers where they are cached until the associated XID is committed or
rolled back. If the transaction is successfully committed, through the 2PC
protocol the messages will pass through the system.
Similarly, messages that are sent to consumers, either synchronously or asynchronously are also cached by the resource manager until the global transaction completes.
On startup the resource manager will read all incomplete transactions, which are incompleted into memory. It will then process trnasactions that have timed out.
The transaction manager will call the recover(int)
method and obtain a
list of incomplete transaction for the purpose of completing them where
possible.
Field Summary | |
static int |
GC_ASYNCHRONOUS
Asynchronous garbage collection is used to remove processed log files asynchronous (i.e in a different thread context). |
static int |
GC_DISABLED
This is used to indicate the garbage collection has been disabled and that the client will take responsibility for all aspects of log file management. |
static int |
GC_SYNCHRONOUS
Synchronous gabrage collection is used to remove processed log files when the last trnasaction, in that log file, has been successfully processed. |
static java.lang.String |
RM_LOGFILE_EXTENSION
The extension for all transaction log files |
Constructor Summary | |
ResourceManager(java.lang.String dir)
Construct a resource manager using the specified directory, which must already exist. |
Method Summary | |
protected void |
buildLogFileList()
Build a list of all log files in the specified log directory |
void |
commit(javax.transaction.xa.Xid id,
boolean onePhase)
Ensure that a transaction with the specified xid is currently active. |
protected TransactionLog |
createNextTransactionLog()
Create the next TransactionLog and add it to the list of
managed transaction logs. |
void |
end(javax.transaction.xa.Xid id,
int flags)
Ends the work performed on behalf of a transaction branch. |
void |
forget(javax.transaction.xa.Xid id)
Tell the resource manager to forget about a heuristically completed transaction branch. |
void |
garbageCollect()
This is the entry point for the garbage collection callback. |
boolean |
gcDisabled()
Check whether garbage collection has been disabled |
int |
getGCMode()
Return the garbage collection mode for the resource manager |
java.lang.String |
getLogDirectory()
Retrieve the name of the log directory |
int |
getLogFileSize()
Return the maximum size that each log file can grow too. |
java.lang.String |
getResourceManagerId()
Return the resource manager identity |
protected long |
getSequenceNumber(java.lang.String name)
Return the sequence number of the file files are associated with a unique number |
protected java.lang.Object[] |
getTransactionRecords(ExternalXid xid,
java.lang.String rid)
Return an arrya of records, both state and date, for the specified global transaction |
int |
getTransactionTimeout()
Return the transaction timeout for this instance of the resource manager. |
static ResourceManager |
instance()
Return the singleton instance of the ResourceManager |
boolean |
isSameRM(javax.transaction.xa.XAResource xares)
Ask the resource manager to prepare for a transaction commit of the transaction specified in xid |
void |
logPublishedMessage(javax.transaction.xa.Xid xid,
MessageImpl message)
Log this published message so that it can be passed through the system when the associated global transaction commits. |
void |
logReceivedMessage(javax.transaction.xa.Xid xid,
java.lang.String id,
MessageHandle handle)
Log that this message handle was sent to the consumer within the specified global transaction identity. |
void |
logTransactionState(javax.transaction.xa.Xid xid,
TransactionState state)
Add an StateTransactionLogEntry using the specified txid,
rid and state |
int |
prepare(javax.transaction.xa.Xid id)
Obtain a list of prepared transaction branches from a resource manager. |
javax.transaction.xa.Xid[] |
recover(int flag)
Inform the resource manager to roll back work done on behalf of a transaction branch |
void |
rollback(javax.transaction.xa.Xid id)
Set the current transaction timeout value for this XAResource instance. |
void |
run()
|
boolean |
setGCMode(int mode)
Set the GC mode for the resource manager. |
void |
setLogDirectory(java.lang.String dir)
Set the log directory. |
void |
setLogFileSize(int size)
Set the maximum size of each log file. |
boolean |
setTransactionTimeout(int seconds)
Start work on behalf of a transaction branch specified in xid If TMJOIN is specified, the start is for joining a transaction previously seen by the resource manager |
void |
start()
|
void |
start(javax.transaction.xa.Xid id,
int flags)
|
void |
stop()
|
Methods inherited from class org.exolab.core.service.BasicService |
toString |
Methods inherited from class org.exolab.core.service.Service |
getName, getState, restart, setState |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String RM_LOGFILE_EXTENSION
public static final int GC_DISABLED
This is the default mode for GC.
public static final int GC_SYNCHRONOUS
public static final int GC_ASYNCHRONOUS
Constructor Detail |
public ResourceManager(java.lang.String dir) throws ResourceManagerException
dir
- - the base directoryResourceManagerException
- Method Detail |
public static ResourceManager instance() throws ResourceManagerException
ResourceManagerException
- public void setLogDirectory(java.lang.String dir) throws java.lang.IllegalArgumentException
dir
- - the name of the directory (absolute or relative)java.lang.IllegalArgumentException
- if the string is not a directorypublic java.lang.String getLogDirectory()
public void setLogFileSize(int size)
The size is specified in bytes
size
- - the max size of each log filepublic int getLogFileSize()
public boolean setGCMode(int mode)
mode
- - one of GC_*public int getGCMode()
public boolean gcDisabled()
public void logPublishedMessage(javax.transaction.xa.Xid xid, MessageImpl message) throws TransactionLogException, ResourceManagerException, javax.jms.JMSException
xid
- - the global transaction identitymessage
- - the message publishedTransactionLogException
- - error adding the entryResourceManagerException
- - error getting the trnasaction logjavax.jms.JMSException
- - if there is an issue with prep'ing the messagepublic void logReceivedMessage(javax.transaction.xa.Xid xid, java.lang.String id, MessageHandle handle) throws TransactionLogException, ResourceManagerException
txid
- - the global transaction identityid
- - the consumer receiving this messagehandle
- - the handle of the message receivedTransactionLogException
- - error adding the entryResourceManagerException
- - error getting the transaction logpublic void logTransactionState(javax.transaction.xa.Xid xid, TransactionState state) throws TransactionLogException, ResourceManagerException
StateTransactionLogEntry
using the specified txid,
rid and statexid
- - the transaction identifierstate
- - the transaction log stateTransactionLogException
- - error adding the entryResourceManagerException
- - error getting the trnasaction logpublic void garbageCollect()
public void commit(javax.transaction.xa.Xid id, boolean onePhase) throws javax.transaction.xa.XAException
This will have the effect of passing all messages through
xid
- - the xa transaction identityonePhase
- - treu if it is a one phase commitjavax.transaction.xa.XAException
- - if there is a problem completing the callpublic void end(javax.transaction.xa.Xid id, int flags) throws javax.transaction.xa.XAException
xid
- - the xa transaction identityflags
- - one of TMSUCCESS, TMFAIL, or TMSUSPENDjavax.transaction.xa.XAException
- - if there is a problem completing the callpublic void forget(javax.transaction.xa.Xid id) throws javax.transaction.xa.XAException
xid
- - the xa transaction identityjavax.transaction.xa.XAException
- - if there is a problem completing the callpublic int getTransactionTimeout() throws javax.transaction.xa.XAException
javax.transaction.xa.XAException
- - if there is a problem completing the callpublic boolean isSameRM(javax.transaction.xa.XAResource xares) throws javax.transaction.xa.XAException
xid
- - the xa transaction identityjavax.transaction.xa.XAException
- - if there is a problem completing the callpublic int prepare(javax.transaction.xa.Xid id) throws javax.transaction.xa.XAException
flag
- - One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGSXid[]
- - the set of Xids to recoverjavax.transaction.xa.XAException
- - if there is a problem completing the callpublic javax.transaction.xa.Xid[] recover(int flag) throws javax.transaction.xa.XAException
xid
- - the xa transaction identityjavax.transaction.xa.XAException
- - if there is a problem completing the callpublic void rollback(javax.transaction.xa.Xid id) throws javax.transaction.xa.XAException
seconds
- - timeout in secondsjavax.transaction.xa.XAException
- - if there is a problem completing the callpublic boolean setTransactionTimeout(int seconds) throws javax.transaction.xa.XAException
xid
- - the xa transaction identityflags
- - One of TMNOFLAGS, TMJOIN, or TMRESUMEjavax.transaction.xa.XAException
- - if there is a problem completing the callpublic void start(javax.transaction.xa.Xid id, int flags) throws javax.transaction.xa.XAException
public void start() throws org.exolab.core.service.ServiceException
start
in class org.exolab.core.service.BasicService
public void stop() throws org.exolab.core.service.ServiceException
stop
in class org.exolab.core.service.BasicService
public void run()
run
in class org.exolab.core.service.BasicService
public java.lang.String getResourceManagerId()
protected TransactionLog createNextTransactionLog() throws ResourceManagerException
TransactionLog
and add it to the list of
managed transaction logs.
The method will throw ResourceManagerException if there is a problem completing the request.
ResourceManagerException
- protected void buildLogFileList()
java.lang.IllegalArgumentException
- - if the directory does not exist.protected java.lang.Object[] getTransactionRecords(ExternalXid xid, java.lang.String rid)
xid
- - the global transaction idrid
- - the resource idprotected long getSequenceNumber(java.lang.String name) throws ResourceManagerException
name
- - the file name to investigateResourceManagerException
-
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |