|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.exolab.jms.service.Service | +--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 theMessageMgr
. 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(MessageManager messages,
DestinationManager destinations,
DatabaseService database)
Construct a resource manager using the default directory for its log files. |
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 |
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. |
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,
long 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. |
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(javax.transaction.xa.Xid id,
int flags)
|
Methods inherited from class org.exolab.jms.service.Service |
doStart, doStop, getName, isStarted, restart, start, stop, toString |
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
public static final int GC_SYNCHRONOUS
public static final int GC_ASYNCHRONOUS
Constructor Detail |
public ResourceManager(MessageManager messages, DestinationManager destinations, DatabaseService database) throws ResourceManagerException
messages
- the message managerdestinations
- the destination managerdatabase
- the database serviceResourceManagerException
- Method Detail |
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, long id, MessageHandle handle) throws TransactionLogException, ResourceManagerException
xid
- 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
id
- - 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
id
- - 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
id
- - 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
xares
- javax.transaction.xa.XAException
- - if there is a problem completing the callpublic int prepare(javax.transaction.xa.Xid id) throws javax.transaction.xa.XAException
javax.transaction.xa.XAException
- - if there is a problem completing the callpublic javax.transaction.xa.Xid[] recover(int flag) throws javax.transaction.xa.XAException
javax.transaction.xa.XAException
- - if there is a problem completing the callpublic void rollback(javax.transaction.xa.Xid id) throws javax.transaction.xa.XAException
javax.transaction.xa.XAException
- - if there is a problem completing the callpublic boolean setTransactionTimeout(int seconds) throws javax.transaction.xa.XAException
javax.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 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 |