org.jboss.mq.pm.jdbc2
Class PersistenceManager

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

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

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

Version:
$Revision: 1.29.2.6 $
Author:
Jayesh Parayali (jayeshpk1@yahoo.com), Hiram Chirino (cojonudo14@hotmail.com)

Nested Class Summary
protected  class PersistenceManager.TransactionManagerStrategy
          This inner class helps handle the tx management of the jdbc connections.
 
Field Summary
protected static int BINARYSTREAM_BLOB
           
protected static int BLOB_BLOB
           
protected  int blobType
           
protected static int BYTES_BLOB
           
protected  javax.management.ObjectName connectionManagerName
          The object name of the DataSource
protected  int connectionRetryAttempts
           
protected  String CREATE_IDX_MESSAGE_DESTINATION
           
protected  String CREATE_IDX_MESSAGE_TXOP_TXID
           
protected  String CREATE_MESSAGE_TABLE
           
protected  String CREATE_TX_TABLE
           
protected  boolean createTables
           
protected  DataSource datasource
          The DataSource
protected  String DELETE_ALL_TX
           
protected  String DELETE_MARKED_MESSAGES
           
protected  String DELETE_MARKED_MESSAGES_WITH_TX
           
protected  String DELETE_MESSAGE
           
protected  String DELETE_TEMPORARY_MESSAGES
           
protected  String DELETE_TX
           
protected  String INSERT_MESSAGE
           
protected  String INSERT_TX
           
protected  String MARK_MESSAGE
           
protected  EDU.oswego.cs.dl.util.concurrent.SynchronizedLong nextTransactionId
          The next transaction id
protected static int OBJECT_BLOB
           
protected  String SELECT_MAX_TX
           
protected  String SELECT_MESSAGE
           
protected  String SELECT_MESSAGES_IN_DEST
           
protected  Properties sqlProperties
          The SQL properties
protected  TransactionManager tm
          The JBossMQ transaction mananger
protected  TxManager txManager
          The jta transaction manager
protected  String UPDATE_MARKED_MESSAGES
           
protected  String UPDATE_MARKED_MESSAGES_WITH_TX
           
protected  String UPDATE_MESSAGE
           
 
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()
           
 
Method Summary
protected  void add(Connection c, String queue, SpyMessage message, Tx txId, String mark)
           
 void add(MessageReference messageRef, Tx txId)
          Add a message to the persistent store.
 void addTXRecord(Connection c, long txid)
           
 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  void createSchema()
           
protected  Connection getConnection()
          Gets a connection from the datasource, retrying as needed.
 javax.management.ObjectName getConnectionManager()
           
 int getConnectionRetryAttempts()
          Gets the ConnectionRetryAttempts.
 Object getInstance()
          Describe getInstance method here.
 javax.management.ObjectName getMessageCache()
          Describe getMessageCache method here.
 MessageCache getMessageCacheInstance()
          Get the message cache
 int getRecoveryRetries()
           
 int getRecoveryTimeout()
           
 String getSqlProperties()
          Gets the sqlProperties.
 TxManager getTxManager()
          Get a transaction manager.
 void insertPersistentTx(PersistenceManager.TransactionManagerStrategy tms, Connection c, Tx tx)
           
protected  void internalRestoreQueue(JMSDestination jmsDest, SpyDestination dest)
           
 SpyMessage loadFromStorage(MessageReference messageRef)
          Reads the message refered to by the MessagReference back as a SpyMessage
 void markMessage(Connection c, long messageid, String destination, Tx txId, String mark)
           
 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.
 void removeMarkedMessages(Connection c, Tx txid, String mark)
           
 void removeTXRecord(Connection c, long txid)
           
protected  void resolveAllUncommitedTXs()
           
 void restoreQueue(JMSDestination jmsDest, SpyDestination dest)
          Restore a queue.
 void rollbackPersistentTx(Tx txId)
          Rollback the transaction.
 void saveToStorage(MessageReference messageRef, SpyMessage message)
          Stores the given message to secondary storeage.
 void setBlob(PreparedStatement stmt, int column, SpyMessage message)
           
 void setConnectionManager(javax.management.ObjectName connectionManagerName)
           
 void setConnectionRetryAttempts(int value)
          Sets the ConnectionRetryAttempts.
 void setMessageCache(javax.management.ObjectName messageCache)
          Describe setMessageCache method here.
 void setRecoveryRetries(int retries)
           
 void setRecoveryTimeout(int timeout)
           
 void setSqlProperties(String value)
          Sets the sqlProperties.
 void startService()
           
 void update(MessageReference messageRef, Tx txId)
          Update message in the persistent store.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, createService, destroy, destroyService, getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop, stopService
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, 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
 

Field Detail

nextTransactionId

protected EDU.oswego.cs.dl.util.concurrent.SynchronizedLong nextTransactionId
The next transaction id


txManager

protected TxManager txManager
The jta transaction manager


datasource

protected DataSource datasource
The DataSource


tm

protected TransactionManager tm
The JBossMQ transaction mananger


UPDATE_MARKED_MESSAGES

protected String UPDATE_MARKED_MESSAGES

UPDATE_MARKED_MESSAGES_WITH_TX

protected String UPDATE_MARKED_MESSAGES_WITH_TX

DELETE_MARKED_MESSAGES_WITH_TX

protected String DELETE_MARKED_MESSAGES_WITH_TX

DELETE_TX

protected String DELETE_TX

DELETE_MARKED_MESSAGES

protected String DELETE_MARKED_MESSAGES

DELETE_TEMPORARY_MESSAGES

protected String DELETE_TEMPORARY_MESSAGES

INSERT_TX

protected String INSERT_TX

DELETE_ALL_TX

protected String DELETE_ALL_TX

SELECT_MAX_TX

protected String SELECT_MAX_TX

SELECT_MESSAGES_IN_DEST

protected String SELECT_MESSAGES_IN_DEST

SELECT_MESSAGE

protected String SELECT_MESSAGE

INSERT_MESSAGE

protected String INSERT_MESSAGE

MARK_MESSAGE

protected String MARK_MESSAGE

DELETE_MESSAGE

protected String DELETE_MESSAGE

UPDATE_MESSAGE

protected String UPDATE_MESSAGE

CREATE_MESSAGE_TABLE

protected String CREATE_MESSAGE_TABLE

CREATE_IDX_MESSAGE_TXOP_TXID

protected String CREATE_IDX_MESSAGE_TXOP_TXID

CREATE_IDX_MESSAGE_DESTINATION

protected String CREATE_IDX_MESSAGE_DESTINATION

CREATE_TX_TABLE

protected String CREATE_TX_TABLE

OBJECT_BLOB

protected static final int OBJECT_BLOB
See Also:
Constant Field Values

BYTES_BLOB

protected static final int BYTES_BLOB
See Also:
Constant Field Values

BINARYSTREAM_BLOB

protected static final int BINARYSTREAM_BLOB
See Also:
Constant Field Values

BLOB_BLOB

protected static final int BLOB_BLOB
See Also:
Constant Field Values

blobType

protected int blobType

createTables

protected boolean createTables

connectionRetryAttempts

protected int connectionRetryAttempts

connectionManagerName

protected javax.management.ObjectName connectionManagerName
The object name of the DataSource


sqlProperties

protected Properties sqlProperties
The SQL properties

Constructor Detail

PersistenceManager

public PersistenceManager()
                   throws javax.jms.JMSException
Throws:
javax.jms.JMSException
Method Detail

createSchema

protected void createSchema()
                     throws javax.jms.JMSException
Throws:
javax.jms.JMSException

resolveAllUncommitedTXs

protected void resolveAllUncommitedTXs()
                                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

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

internalRestoreQueue

protected void internalRestoreQueue(JMSDestination jmsDest,
                                    SpyDestination dest)
                             throws javax.jms.JMSException
Throws:
javax.jms.JMSException

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

removeMarkedMessages

public void removeMarkedMessages(Connection c,
                                 Tx txid,
                                 String mark)
                          throws SQLException
Throws:
SQLException

addTXRecord

public void addTXRecord(Connection c,
                        long txid)
                 throws SQLException
Throws:
SQLException

removeTXRecord

public void removeTXRecord(Connection c,
                           long txid)
                    throws SQLException
Throws:
SQLException

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

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

insertPersistentTx

public void insertPersistentTx(PersistenceManager.TransactionManagerStrategy tms,
                               Connection c,
                               Tx tx)
                        throws javax.jms.JMSException
Throws:
javax.jms.JMSException

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

add

protected void add(Connection c,
                   String queue,
                   SpyMessage message,
                   Tx txId,
                   String mark)
            throws SQLException,
                   IOException
Throws:
SQLException
IOException

markMessage

public void markMessage(Connection c,
                        long messageid,
                        String destination,
                        Tx txId,
                        String mark)
                 throws SQLException
Throws:
SQLException

setBlob

public void setBlob(PreparedStatement stmt,
                    int column,
                    SpyMessage message)
             throws IOException,
                    SQLException
Throws:
IOException
SQLException

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
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

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

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

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.

startService

public void startService()
                  throws Exception
Overrides:
startService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception

getInstance

public Object getInstance()
Describe getInstance method here.

Specified by:
getInstance in interface CacheStoreMBean
Specified by:
getInstance in interface PersistenceManagerMBean
Returns:
an Object value

getMessageCache

public javax.management.ObjectName getMessageCache()
Describe getMessageCache method here.

Specified by:
getMessageCache in interface PersistenceManagerMBean
Returns:
an ObjectName value

setMessageCache

public void setMessageCache(javax.management.ObjectName messageCache)
Describe setMessageCache method here.

Specified by:
setMessageCache in interface PersistenceManagerMBean
Parameters:
messageCache - an ObjectName value

getConnectionManager

public javax.management.ObjectName getConnectionManager()

setConnectionManager

public void setConnectionManager(javax.management.ObjectName connectionManagerName)

getMessageCacheInstance

public MessageCache getMessageCacheInstance()
Description copied from interface: PersistenceManager
Get the message cache

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

getSqlProperties

public String getSqlProperties()
Gets the sqlProperties.

Returns:
Returns a Properties

setSqlProperties

public void setSqlProperties(String value)
Sets the sqlProperties.

Parameters:
sqlProperties - The sqlProperties to set

setConnectionRetryAttempts

public void setConnectionRetryAttempts(int value)
Sets the ConnectionRetryAttempts.

Parameters:
connectionRetryAttempts - value

getConnectionRetryAttempts

public int getConnectionRetryAttempts()
Gets the ConnectionRetryAttempts.

Returns:
Returns a ConnectionRetryAttempt value

getRecoveryTimeout

public int getRecoveryTimeout()

setRecoveryTimeout

public void setRecoveryTimeout(int timeout)

getRecoveryRetries

public int getRecoveryRetries()

setRecoveryRetries

public void setRecoveryRetries(int retries)


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