org.apache.qpid.server.store
Class DerbyMessageStore

java.lang.Object
  extended by org.apache.qpid.server.store.DerbyMessageStore
All Implemented Interfaces:
DurableConfigurationStore, MessageStore, TransactionLog

public class DerbyMessageStore
extends Object
implements MessageStore

An implementation of a MessageStore that uses Apache Derby as the persistance mechanism. TODO extract the SQL statements into a generic JDBC store


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.qpid.server.store.DurableConfigurationStore
DurableConfigurationStore.Source
 
Nested classes/interfaces inherited from interface org.apache.qpid.server.store.TransactionLog
TransactionLog.StoreFuture, TransactionLog.Transaction
 
Field Summary
static String ENVIRONMENT_PATH_PROPERTY
           
 
Fields inherited from interface org.apache.qpid.server.store.MessageStore
IMMEDIATE_FUTURE
 
Constructor Summary
DerbyMessageStore()
           
 
Method Summary
 void abortTran(org.apache.qpid.server.store.DerbyMessageStore.ConnectionWrapper connWrapper)
           
 StoredMessage addMessage(StorableMessageMetaData metaData)
           
 void bindQueue(Exchange exchange, org.apache.qpid.framing.AMQShortString routingKey, AMQQueue queue, org.apache.qpid.framing.FieldTable args)
          Binds the specified queue to an exchange with a routing key.
 void close()
          Called to close and cleanup any resources used by the message store.
 void commitTran(org.apache.qpid.server.store.DerbyMessageStore.ConnectionWrapper connWrapper)
           
 TransactionLog.StoreFuture commitTranAsync(org.apache.qpid.server.store.DerbyMessageStore.ConnectionWrapper connWrapper)
           
 void configureConfigStore(String name, ConfigurationRecoveryHandler recoveryHandler, Configuration storeConfiguration, LogSubject logSubject)
          Called after instantiation in order to configure the message store.
 void configureMessageStore(String name, MessageStoreRecoveryHandler recoveryHandler, Configuration storeConfiguration, LogSubject logSubject)
          Called after instantiation in order to configure the message store.
 void configureTransactionLog(String name, TransactionLogRecoveryHandler recoveryHandler, Configuration storeConfiguration, LogSubject logSubject)
           
 void createExchange(Exchange exchange)
          Makes the specified exchange persistent.
 void createQueue(AMQQueue queue)
          Makes the specified queue persistent.
 void createQueue(AMQQueue queue, org.apache.qpid.framing.FieldTable arguments)
          Makes the specified queue persistent.
 void dequeueMessage(org.apache.qpid.server.store.DerbyMessageStore.ConnectionWrapper connWrapper, TransactionLogResource queue, Long messageId)
           
 void enqueueMessage(org.apache.qpid.server.store.DerbyMessageStore.ConnectionWrapper connWrapper, TransactionLogResource queue, Long messageId)
           
 int getContent(long messageId, int offset, ByteBuffer dst)
           
 StoredMessage getMessage(long messageNumber)
           
(package private)  StorableMessageMetaData getMetaData(long messageId)
           
 Long getNewMessageId()
           
 boolean isPersistent()
          Is this store capable of persisting the data
 TransactionLog.Transaction newTransaction()
           
 void recover(ConfigurationRecoveryHandler recoveryHandler)
           
 void removeExchange(Exchange exchange)
          Removes the specified persistent exchange.
 void removeMessage(long messageId)
           
 void removeQueue(AMQQueue queue)
          Removes the specified queue from the persistent store.
 void unbindQueue(Exchange exchange, org.apache.qpid.framing.AMQShortString routingKey, AMQQueue queue, org.apache.qpid.framing.FieldTable args)
          Unbinds the specified from an exchange under a particular routing key.
 void updateQueue(AMQQueue queue)
          Updates the specified queue in the persistent store, IF it is already present.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENVIRONMENT_PATH_PROPERTY

public static final String ENVIRONMENT_PATH_PROPERTY
See Also:
Constant Field Values
Constructor Detail

DerbyMessageStore

public DerbyMessageStore()
Method Detail

configureConfigStore

public void configureConfigStore(String name,
                                 ConfigurationRecoveryHandler recoveryHandler,
                                 Configuration storeConfiguration,
                                 LogSubject logSubject)
                          throws Exception
Description copied from interface: DurableConfigurationStore
Called after instantiation in order to configure the message store. A particular implementation can define whatever parameters it wants.

Specified by:
configureConfigStore in interface DurableConfigurationStore
Parameters:
name - The name to be used by this storem
recoveryHandler - Handler to be called as the store recovers on start up
storeConfiguration - The apache commons configuration object.
Throws:
Exception - If any error occurs that means the store is unable to configure itself.

configureMessageStore

public void configureMessageStore(String name,
                                  MessageStoreRecoveryHandler recoveryHandler,
                                  Configuration storeConfiguration,
                                  LogSubject logSubject)
                           throws Exception
Description copied from interface: MessageStore
Called after instantiation in order to configure the message store. A particular implementation can define whatever parameters it wants.

Specified by:
configureMessageStore in interface MessageStore
Parameters:
name - The name to be used by this storem
recoveryHandler - Handler to be called as the store recovers on start up
storeConfiguration - The apache commons configuration object.
Throws:
Exception - If any error occurs that means the store is unable to configure itself.

configureTransactionLog

public void configureTransactionLog(String name,
                                    TransactionLogRecoveryHandler recoveryHandler,
                                    Configuration storeConfiguration,
                                    LogSubject logSubject)
                             throws Exception
Specified by:
configureTransactionLog in interface TransactionLog
Throws:
Exception

recover

public void recover(ConfigurationRecoveryHandler recoveryHandler)
             throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

close

public void close()
           throws Exception
Description copied from interface: MessageStore
Called to close and cleanup any resources used by the message store.

Specified by:
close in interface MessageStore
Throws:
Exception - If the close fails.

addMessage

public StoredMessage addMessage(StorableMessageMetaData metaData)
Specified by:
addMessage in interface MessageStore

getMessage

public StoredMessage getMessage(long messageNumber)

removeMessage

public void removeMessage(long messageId)

createExchange

public void createExchange(Exchange exchange)
                    throws org.apache.qpid.AMQStoreException
Description copied from interface: DurableConfigurationStore
Makes the specified exchange persistent.

Specified by:
createExchange in interface DurableConfigurationStore
Parameters:
exchange - The exchange to persist.
Throws:
org.apache.qpid.AMQStoreException - If the operation fails for any reason.

removeExchange

public void removeExchange(Exchange exchange)
                    throws org.apache.qpid.AMQStoreException
Description copied from interface: DurableConfigurationStore
Removes the specified persistent exchange.

Specified by:
removeExchange in interface DurableConfigurationStore
Parameters:
exchange - The exchange to remove.
Throws:
org.apache.qpid.AMQStoreException - If the operation fails for any reason.

bindQueue

public void bindQueue(Exchange exchange,
                      org.apache.qpid.framing.AMQShortString routingKey,
                      AMQQueue queue,
                      org.apache.qpid.framing.FieldTable args)
               throws org.apache.qpid.AMQStoreException
Description copied from interface: DurableConfigurationStore
Binds the specified queue to an exchange with a routing key.

Specified by:
bindQueue in interface DurableConfigurationStore
Parameters:
exchange - The exchange to bind to.
routingKey - The routing key to bind by.
queue - The queue to bind.
args - Additional parameters.
Throws:
org.apache.qpid.AMQStoreException - if the operation fails for any reason.

unbindQueue

public void unbindQueue(Exchange exchange,
                        org.apache.qpid.framing.AMQShortString routingKey,
                        AMQQueue queue,
                        org.apache.qpid.framing.FieldTable args)
                 throws org.apache.qpid.AMQStoreException
Description copied from interface: DurableConfigurationStore
Unbinds the specified from an exchange under a particular routing key.

Specified by:
unbindQueue in interface DurableConfigurationStore
Parameters:
exchange - The exchange to unbind from.
routingKey - The routing key to unbind.
queue - The queue to unbind.
args - Additonal parameters.
Throws:
org.apache.qpid.AMQStoreException - If the operation fails for any reason.

createQueue

public void createQueue(AMQQueue queue)
                 throws org.apache.qpid.AMQStoreException
Description copied from interface: DurableConfigurationStore
Makes the specified queue persistent.

Specified by:
createQueue in interface DurableConfigurationStore
Parameters:
queue - The queue to store.
Throws:
org.apache.qpid.AMQStoreException - If the operation fails for any reason.

createQueue

public void createQueue(AMQQueue queue,
                        org.apache.qpid.framing.FieldTable arguments)
                 throws org.apache.qpid.AMQStoreException
Description copied from interface: DurableConfigurationStore
Makes the specified queue persistent.

Specified by:
createQueue in interface DurableConfigurationStore
Parameters:
queue - The queue to store.
arguments - The additional arguments to the binding
Throws:
org.apache.qpid.AMQStoreException - If the operation fails for any reason.

updateQueue

public void updateQueue(AMQQueue queue)
                 throws org.apache.qpid.AMQStoreException
Updates the specified queue in the persistent store, IF it is already present. If the queue is not present in the store, it will not be added. NOTE: Currently only updates the exclusivity.

Specified by:
updateQueue in interface DurableConfigurationStore
Parameters:
queue - The queue to update the entry for.
Throws:
org.apache.qpid.AMQStoreException - If the operation fails for any reason.

removeQueue

public void removeQueue(AMQQueue queue)
                 throws org.apache.qpid.AMQStoreException
Description copied from interface: DurableConfigurationStore
Removes the specified queue from the persistent store.

Specified by:
removeQueue in interface DurableConfigurationStore
Parameters:
queue - The queue to remove.
Throws:
org.apache.qpid.AMQStoreException - If the operation fails for any reason.

newTransaction

public TransactionLog.Transaction newTransaction()
Specified by:
newTransaction in interface TransactionLog

enqueueMessage

public void enqueueMessage(org.apache.qpid.server.store.DerbyMessageStore.ConnectionWrapper connWrapper,
                           TransactionLogResource queue,
                           Long messageId)
                    throws org.apache.qpid.AMQStoreException
Throws:
org.apache.qpid.AMQStoreException

dequeueMessage

public void dequeueMessage(org.apache.qpid.server.store.DerbyMessageStore.ConnectionWrapper connWrapper,
                           TransactionLogResource queue,
                           Long messageId)
                    throws org.apache.qpid.AMQStoreException
Throws:
org.apache.qpid.AMQStoreException

commitTran

public void commitTran(org.apache.qpid.server.store.DerbyMessageStore.ConnectionWrapper connWrapper)
                throws org.apache.qpid.AMQStoreException
Throws:
org.apache.qpid.AMQStoreException

commitTranAsync

public TransactionLog.StoreFuture commitTranAsync(org.apache.qpid.server.store.DerbyMessageStore.ConnectionWrapper connWrapper)
                                           throws org.apache.qpid.AMQStoreException
Throws:
org.apache.qpid.AMQStoreException

abortTran

public void abortTran(org.apache.qpid.server.store.DerbyMessageStore.ConnectionWrapper connWrapper)
               throws org.apache.qpid.AMQStoreException
Throws:
org.apache.qpid.AMQStoreException

getNewMessageId

public Long getNewMessageId()

getMetaData

StorableMessageMetaData getMetaData(long messageId)
                              throws SQLException
Throws:
SQLException

getContent

public int getContent(long messageId,
                      int offset,
                      ByteBuffer dst)

isPersistent

public boolean isPersistent()
Description copied from interface: MessageStore
Is this store capable of persisting the data

Specified by:
isPersistent in interface MessageStore
Returns:
true if this store is capable of persisting data


Licensed to the Apache Software Foundation