站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 messaging API Documentation 英文版文档

PersistenceManager (JBoss Messaging API) - JBoss 4.0.1 sp1 messaging API Documentation 英文版文档


org.jboss.mq.pm.jdbc3
Class PersistenceManager

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended byorg.jboss.system.ServiceMBeanSupport
          extended byorg.jboss.mq.pm.jdbc3.PersistenceManager
All Implemented Interfaces:
CacheStore, CacheStoreMBean, javax.management.MBeanRegistration, NewPersistenceManager, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, PersistenceManager, PersistenceManagerMBean, PersistenceManagerMBean, Runnable, org.jboss.system.Service, org.jboss.system.ServiceMBean

public class PersistenceManager
extends org.jboss.system.ServiceMBeanSupport
implements PersistenceManagerMBean, NewPersistenceManager, CacheStore, Runnable

This class manages all persistence related services for JDBC based persistence.

Version:
$Revision: 1.6.4.2 $
Author:
Jayesh Parayali (jayeshpk1@yahoo.com), Hiram Chirino (cojonudo14@hotmail.com), Adrian Brock (adrian@jboss.org)

Field Summary
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Fields inherited from interface org.jboss.mq.pm.PersistenceManagerMBean
OBJECT_NAME
 
Constructor Summary
PersistenceManager()
          Create a new persistence manager
 
Method Summary
 void add(MessageReference messageRef, Tx txId)
          Add a message to the persistent store.
protected  void addMessage(Connection c, String queue, SpyMessage message, Tx txId, String mark, String lateClone)
          Add a message
 void addMessage(SpyMessage message)
          Persist the message
protected  void addReference(Connection c, String queue, MessageReference message, Tx txId, String mark)
          Add a reference
 void closeQueue(JMSDestination jmsDest, SpyDestination dest)
          Close a queue
 void commitPersistentTx(Tx txId)
          Commit the transaction to the persistent store.
 Tx createPersistentTx()
          Create and return a unique transaction id.
protected  SpyMessage extractMessage(ResultSet rs, int column)
          Extract a message from a result
protected  Connection getConnection()
          Gets a connection from the datasource, retrying as needed.
 javax.management.ObjectName getConnectionManager()
          Retrieve the connection manager object name
 int getConnectionRetryAttempts()
          Gets the ConnectionRetryAttempts.
 int getGCPeriodSecs()
          Set the garbage collection period
 Object getInstance()
          Get the persistence manager instance
 javax.management.ObjectName getMessageCache()
          Unsupported operation
 MessageCache getMessageCacheInstance()
          Unsupported operation
 String getSqlProperties()
          Gets the sqlProperties.
 TxManager getTxManager()
          Get a transaction manager.
 SpyMessage loadFromStorage(MessageReference messageRef)
          Reads the message refered to by the MessagReference back as a SpyMessage
 void remove(MessageReference messageRef, Tx txId)
          Remove message from the persistent store.
 void removeFromStorage(MessageReference messageRef)
          Removes the message that was stored in secondary storage.
protected  void removeMarkedMessages(Connection c, Tx txid, String mark)
          Remove messages for a given transaction and mark
protected  void removeMarkedReferences(Connection c, Tx txid, String mark)
          Remove references for a given transaction and mark
protected  void removeTXRecord(Connection c, long txid)
          Remove a transaction record
protected  void resolveAllUncommitedTXs()
          Resolve uncommitted transactions
 void restoreQueue(JMSDestination jmsDest, SpyDestination dest)
          Restore a queue.
 void rollbackPersistentTx(Tx txId)
          Rollback the transaction.
 void run()
           
 void saveToStorage(MessageReference messageRef, SpyMessage message)
          Stores the given message to secondary storeage.
protected  void setBlob(PreparedStatement stmt, int column, SpyMessage message)
          Store the message in a blob
 void setConnectionManager(javax.management.ObjectName connectionManagerName)
          Set the connection manager object name
 void setConnectionRetryAttempts(int value)
          Sets the ConnectionRetryAttempts.
 void setGCPeriodSecs(int gcPeriodSecs)
          Set the garbage collection period in seconds
 void setMessageCache(javax.management.ObjectName messageCache)
          Unsupported operation
 void setSqlProperties(String value)
          Sets the sqlProperties.
protected  void startService()
           
protected  void stopService()
           
 void update(MessageReference messageRef, Tx txId)
          Update message in the persistent store.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Constructor Detail

PersistenceManager

public PersistenceManager()
                   throws javax.jms.JMSException
Create a new persistence manager

Throws:
javax.jms.JMSException - for any error
Method Detail

getConnectionManager

public javax.management.ObjectName getConnectionManager()
Retrieve the connection manager object name

Specified by:
getConnectionManager in interface PersistenceManagerMBean

setConnectionManager

public void setConnectionManager(javax.management.ObjectName connectionManagerName)
Set the connection manager object name

Specified by:
setConnectionManager in interface PersistenceManagerMBean

getGCPeriodSecs

public int getGCPeriodSecs()
Set the garbage collection period

Specified by:
getGCPeriodSecs in interface PersistenceManagerMBean

setGCPeriodSecs

public void setGCPeriodSecs(int gcPeriodSecs)
Set the garbage collection period in seconds

Specified by:
setGCPeriodSecs in interface PersistenceManagerMBean

getConnectionRetryAttempts

public int getConnectionRetryAttempts()
Gets the ConnectionRetryAttempts.

Specified by:
getConnectionRetryAttempts in interface PersistenceManagerMBean
Returns:
the number of retry events

setConnectionRetryAttempts

public void setConnectionRetryAttempts(int value)
Sets the ConnectionRetryAttempts.

Specified by:
setConnectionRetryAttempts in interface PersistenceManagerMBean
Parameters:
value - the number of retry attempts

getSqlProperties

public String getSqlProperties()
Gets the sqlProperties.

Specified by:
getSqlProperties in interface PersistenceManagerMBean
Returns:
Returns the Properties

setSqlProperties

public void setSqlProperties(String value)
Sets the sqlProperties.

Specified by:
setSqlProperties in interface PersistenceManagerMBean

createPersistentTx

public Tx createPersistentTx()
                      throws javax.jms.JMSException
Description copied from interface: PersistenceManager
Create and return a unique transaction id.

Specified by:
createPersistentTx in interface PersistenceManager
Returns:
the transaction
Throws:
javax.jms.JMSException - for any error

commitPersistentTx

public void commitPersistentTx(Tx txId)
                        throws javax.jms.JMSException
Description copied from interface: PersistenceManager
Commit the transaction to the persistent store.

Specified by:
commitPersistentTx in interface PersistenceManager
Parameters:
txId - Description of Parameter
Throws:
javax.jms.JMSException - for any error

rollbackPersistentTx

public void rollbackPersistentTx(Tx txId)
                          throws javax.jms.JMSException
Description copied from interface: PersistenceManager
Rollback the transaction.

Specified by:
rollbackPersistentTx in interface PersistenceManager
Parameters:
txId - Description of Parameter
Throws:
javax.jms.JMSException - for any error

add

public void add(MessageReference messageRef,
                Tx txId)
         throws javax.jms.JMSException
Description copied from interface: PersistenceManager
Add a message to the persistent store. If the message is part of a transaction, txId is not null.

Specified by:
add in interface PersistenceManager
Parameters:
messageRef - the message
txId - the transaction
Throws:
javax.jms.JMSException - for any error

update

public void update(MessageReference messageRef,
                   Tx txId)
            throws javax.jms.JMSException
Description copied from interface: PersistenceManager
Update message in the persistent store. If the message is part of a transaction, txId is not null (not currently supported).

Specified by:
update in interface PersistenceManager
Parameters:
messageRef -
txId - Description of Parameter
Throws:
javax.jms.JMSException - for any error

remove

public void remove(MessageReference messageRef,
                   Tx txId)
            throws javax.jms.JMSException
Description copied from interface: PersistenceManager
Remove message from the persistent store. If the message is part of a transaction, txId is not null.

Specified by:
remove in interface PersistenceManager
Parameters:
messageRef - the message
txId - the transaction
Throws:
javax.jms.JMSException - for any error

restoreQueue

public void restoreQueue(JMSDestination jmsDest,
                         SpyDestination dest)
                  throws javax.jms.JMSException
Description copied from interface: PersistenceManager
Restore a queue.

Specified by:
restoreQueue in interface PersistenceManager
Parameters:
jmsDest - the jms destination
dest - the client destination
Throws:
javax.jms.JMSException - for any error

getTxManager

public TxManager getTxManager()
Description copied from interface: PersistenceManager
Get a transaction manager.

Specified by:
getTxManager in interface PersistenceManager
Returns:
the transaction manager

closeQueue

public void closeQueue(JMSDestination jmsDest,
                       SpyDestination dest)
                throws javax.jms.JMSException
Description copied from interface: PersistenceManager
Close a queue

Specified by:
closeQueue in interface PersistenceManager
Parameters:
jmsDest - the jms destination
dest - the client destination
Throws:
javax.jms.JMSException - for any error

getMessageCacheInstance

public MessageCache getMessageCacheInstance()
Unsupported operation

Specified by:
getMessageCacheInstance in interface PersistenceManager
Returns:
the instance of the message cache

addMessage

public void addMessage(SpyMessage message)
                throws javax.jms.JMSException
Description copied from interface: NewPersistenceManager
Persist the message

Specified by:
addMessage in interface NewPersistenceManager
Parameters:
message - the message to persist
Throws:
javax.jms.JMSException - for any error

getInstance

public Object getInstance()
Description copied from interface: PersistenceManagerMBean
Get the persistence manager instance

Specified by:
getInstance in interface PersistenceManagerMBean
Returns:
the persistence manager

getMessageCache

public javax.management.ObjectName getMessageCache()
Unsupported operation

Specified by:
getMessageCache in interface PersistenceManagerMBean
Returns:
the object name of the cache

setMessageCache

public void setMessageCache(javax.management.ObjectName messageCache)
Unsupported operation

Specified by:
setMessageCache in interface PersistenceManagerMBean
Parameters:
messageCache - the object name

loadFromStorage

public SpyMessage loadFromStorage(MessageReference messageRef)
                           throws javax.jms.JMSException
Description copied from interface: CacheStore
Reads the message refered to by the MessagReference back as a SpyMessage

Specified by:
loadFromStorage in interface CacheStore
Parameters:
messageRef - the message reference
Returns:
the message
Throws:
javax.jms.JMSException - for any error

removeFromStorage

public void removeFromStorage(MessageReference messageRef)
                       throws javax.jms.JMSException
Description copied from interface: CacheStore
Removes the message that was stored in secondary storage.

Specified by:
removeFromStorage in interface CacheStore
Parameters:
messageRef - the message reference
Throws:
javax.jms.JMSException - for any error

saveToStorage

public void saveToStorage(MessageReference messageRef,
                          SpyMessage message)
                   throws javax.jms.JMSException
Description copied from interface: CacheStore
Stores the given message to secondary storeage. You should be able to use the MessagReference to load the message back later.

Specified by:
saveToStorage in interface CacheStore
Parameters:
messageRef - the message reference
message - the message
Throws:
javax.jms.JMSException - for any error

run

public void run()
Specified by:
run in interface Runnable

startService

protected void startService()
                     throws Exception
Throws:
Exception

stopService

protected void stopService()
                    throws Exception
Throws:
Exception

resolveAllUncommitedTXs

protected void resolveAllUncommitedTXs()
                                throws javax.jms.JMSException
Resolve uncommitted transactions

Throws:
javax.jms.JMSException - for any error

removeTXRecord

protected void removeTXRecord(Connection c,
                              long txid)
                       throws SQLException
Remove a transaction record

Parameters:
c - the connection
txid - the transaction
Throws:
SQLException - for any error

addMessage

protected void addMessage(Connection c,
                          String queue,
                          SpyMessage message,
                          Tx txId,
                          String mark,
                          String lateClone)
                   throws SQLException,
                          IOException
Add a message

Parameters:
c - the connection
queue - the queue name
message - the message
mark - the mark to set for the message
Throws:
SQLException - for an error in the db
IOException - for an error serializing the message

addReference

protected void addReference(Connection c,
                            String queue,
                            MessageReference message,
                            Tx txId,
                            String mark)
                     throws SQLException,
                            IOException
Add a reference

Parameters:
c - the connection
queue - the queue name
message - the reference
mark - the mark to set for the message
Throws:
SQLException - for an error in the db
IOException - for an error serializing the message

removeMarkedMessages

protected void removeMarkedMessages(Connection c,
                                    Tx txid,
                                    String mark)
                             throws SQLException
Remove messages for a given transaction and mark

Parameters:
c - the connection
txid - the transaction id
mark - the mark
Throws:
SQLException - for any error

removeMarkedReferences

protected void removeMarkedReferences(Connection c,
                                      Tx txid,
                                      String mark)
                               throws SQLException
Remove references for a given transaction and mark

Parameters:
c - the connection
txid - the transaction id
mark - the mark
Throws:
SQLException - for any error

setBlob

protected void setBlob(PreparedStatement stmt,
                       int column,
                       SpyMessage message)
                throws IOException,
                       SQLException
Store the message in a blob

Parameters:
stmt - the prepared statement
column - the column in the prepared statement
message - the message
Throws:
IOException
SQLException

extractMessage

protected SpyMessage extractMessage(ResultSet rs,
                                    int column)
                             throws SQLException,
                                    IOException
Extract a message from a result

Parameters:
rs - the result set
column - the column number
Returns:
the message
Throws:
SQLException - for an error accessing the db
IOException - for an error extracting the message

getConnection

protected Connection getConnection()
                            throws SQLException
Gets a connection from the datasource, retrying as needed. This was implemented because in some minimal configurations (i.e. little logging and few services) the database wasn't ready when we tried to get a connection. We, therefore, implement a retry loop wich is controled by the ConnectionRetryAttempts attribute. Submitted by terry@amicas.com

Throws:
SQLException - if an error occurs.


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.