| Constructor and Description |
|---|
JdbcQueue() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_finishWithRetries(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg,
int numRetries,
int maxRetries)
Performs "finish" action, retry if deadlock.
|
protected Collection<IQueueMessage> |
_getOrphanMessagesWithRetries(long thresholdTimestampMs,
org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
int numRetries,
int maxRetries)
Gets all orphan messages (messages that were left in ephemeral storage
for a long time), retry if deadlock.
|
protected boolean |
_moveFromEphemeralToQueueStorageWithRetries(IQueueMessage msg,
org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
int numRetries,
int maxRetries)
Moves a message from ephemeral back to queue storage, retry if deadlock.
|
protected boolean |
_queueWithRetries(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg,
int numRetries,
int maxRetries)
Queues a message, retry if deadlock.
|
protected boolean |
_requeueSilentWithRetries(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg,
int numRetries,
int maxRetries)
Re-queues a message silently, retry if deadlock.
|
protected boolean |
_requeueWithRetries(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg,
int numRetries,
int maxRetries)
Re-queues a message, retry if deadlock.
|
protected IQueueMessage |
_takeWithRetries(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
int numRetries,
int maxRetries)
Takes a message from queue, retry if deadlock.
|
void |
destroy() |
int |
ephemeralSize()
Gets ephemeral-storage's number of items.
|
void |
finish(IQueueMessage msg)
Called when finish processing the message to cleanup ephemeral storage.
|
protected abstract Collection<IQueueMessage> |
getOrphanFromEphemeralStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
long thresholdTimestampMs)
Gets all orphan messages (messages that were left in ephemeral storage
for a long time).
|
Collection<IQueueMessage> |
getOrphanMessages(long thresholdTimestampMs)
Gets all orphan messages (messages that were left in ephemeral storage
for a long time).
|
protected String |
getTableName() |
protected String |
getTableNameEphemeral() |
JdbcQueue |
init() |
boolean |
moveFromEphemeralToQueueStorage(IQueueMessage msg)
Moves a message from ephemeral back to queue storage.
|
protected abstract boolean |
putToEphemeralStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg)
Puts a message to the ephemeral storage.
|
protected abstract boolean |
putToQueueStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg)
Puts a message to tail of the queue storage.
|
boolean |
queue(IQueueMessage msg)
Queues a message.
|
int |
queueSize()
Gets queue's number of items.
|
protected abstract IQueueMessage |
readFromEphemeralStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg)
Reads a message from the ephemeral storage.
|
protected abstract IQueueMessage |
readFromQueueStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
Reads a message from head of queue storage.
|
protected abstract boolean |
removeFromEphemeralStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg)
Removes a message from the ephemeral storage.
|
protected abstract boolean |
removeFromQueueStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg)
Removes a message from the queue storage.
|
boolean |
requeue(IQueueMessage msg)
Re-queues a message.
|
boolean |
requeueSilent(IQueueMessage msg)
Silently re-queues a message.
|
JdbcQueue |
setTableName(String tableName) |
JdbcQueue |
setTableNameEphemeral(String tableNameEphemeral) |
IQueueMessage |
take()
Takes a message out of queue.
|
commitTransaction, connection, connection, execute, execute, execute, executeSelect, executeSelect, executeSelect, executeSelect, executeSelect, executeSelect, getDataSource, jdbcTemplate, jdbcTemplate, returnConnection, rollbackTransaction, setDataSource, startTransactionaddProfiling, clearProfiling, getCache, getCacheFactory, getFromCache, getFromCache, getProfiling, isCacheEnabled, isCacheItemsExpireAfterWrite, putToCache, putToCache, putToCache, removeFromCache, setCacheFactory, setCacheItemsExpireAfterWrite, startProfilingprotected String getTableName()
protected String getTableNameEphemeral()
public JdbcQueue init()
init in class com.github.ddth.dao.jdbc.BaseJdbcDaopublic void destroy()
destroy in class com.github.ddth.dao.jdbc.BaseJdbcDaoprotected abstract IQueueMessage readFromQueueStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
jdbcTemplate - protected abstract IQueueMessage readFromEphemeralStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, IQueueMessage msg)
jdbcTemplate - msg - protected abstract Collection<IQueueMessage> getOrphanFromEphemeralStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, long thresholdTimestampMs)
jdbcTemplate - thresholdTimestampMs - get all orphan messages that were queued
before this timestampprotected abstract boolean putToQueueStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg)
jdbcTemplate - msg - protected abstract boolean putToEphemeralStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg)
jdbcTemplate - msg - protected abstract boolean removeFromQueueStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg)
jdbcTemplate - msg - protected abstract boolean removeFromEphemeralStorage(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg)
jdbcTemplate - msg - protected boolean _queueWithRetries(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg,
int numRetries,
int maxRetries)
Note: http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
InnoDB uses automatic row-level locking. You can get deadlocks even in the case of transactions that just insert or delete a single row. That is because these operations are not really "atomic"; they automatically set locks on the (possibly several) index records of the row inserted or deleted.
jdbcTemplate - msg - numRetries - maxRetries - public boolean queue(IQueueMessage msg)
Implementation flow:
protected boolean _requeueWithRetries(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg,
int numRetries,
int maxRetries)
Note: http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
InnoDB uses automatic row-level locking. You can get deadlocks even in the case of transactions that just insert or delete a single row. That is because these operations are not really "atomic"; they automatically set locks on the (possibly several) index records of the row inserted or deleted.
jdbcTemplate - msg - numRetries - maxRetries - public boolean requeue(IQueueMessage msg)
Implementation flow:
Note: ephemeral storage implementation is optional, depends on implementation.
protected boolean _requeueSilentWithRetries(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg,
int numRetries,
int maxRetries)
Note: http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
InnoDB uses automatic row-level locking. You can get deadlocks even in the case of transactions that just insert or delete a single row. That is because these operations are not really "atomic"; they automatically set locks on the (possibly several) index records of the row inserted or deleted.
jdbcTemplate - msg - numRetries - maxRetries - public boolean requeueSilent(IQueueMessage msg)
Implementation flow:
Note: ephemeral storage implementation is optional, depends on implementation.
requeueSilent in interface IQueueprotected void _finishWithRetries(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
IQueueMessage msg,
int numRetries,
int maxRetries)
Note: http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
InnoDB uses automatic row-level locking. You can get deadlocks even in the case of transactions that just insert or delete a single row. That is because these operations are not really "atomic"; they automatically set locks on the (possibly several) index records of the row inserted or deleted.
jdbcTemplate - msg - numRetries - maxRetries - public void finish(IQueueMessage msg)
Implementation flow:
Note: ephemeral storage implementation is optional, depends on implementation.
protected IQueueMessage _takeWithRetries(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, int numRetries, int maxRetries)
Note: http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
InnoDB uses automatic row-level locking. You can get deadlocks even in the case of transactions that just insert or delete a single row. That is because these operations are not really "atomic"; they automatically set locks on the (possibly several) index records of the row inserted or deleted.
jdbcTemplate - numRetries - maxRetries - public IQueueMessage take()
Implementation flow:
Note: ephemeral storage implementation is optional, depends on implementation.
protected Collection<IQueueMessage> _getOrphanMessagesWithRetries(long thresholdTimestampMs, org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, int numRetries, int maxRetries)
Note: http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
InnoDB uses automatic row-level locking. You can get deadlocks even in the case of transactions that just insert or delete a single row. That is because these operations are not really "atomic"; they automatically set locks on the (possibly several) index records of the row inserted or deleted.
thresholdTimestampMs - jdbcTemplate - numRetries - maxRetries - public Collection<IQueueMessage> getOrphanMessages(long thresholdTimestampMs)
getOrphanMessages in interface IQueuethresholdTimestampMs - get all orphan messages that were queued
before this timestampprotected boolean _moveFromEphemeralToQueueStorageWithRetries(IQueueMessage msg, org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, int numRetries, int maxRetries)
Note: http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
InnoDB uses automatic row-level locking. You can get deadlocks even in the case of transactions that just insert or delete a single row. That is because these operations are not really "atomic"; they automatically set locks on the (possibly several) index records of the row inserted or deleted.
msg - jdbcTemplate - numRetries - maxRetries - public boolean moveFromEphemeralToQueueStorage(IQueueMessage msg)
Implementation flow:
moveFromEphemeralToQueueStorage in interface IQueuetrue if a move has been made, false otherwise
(e.g. the message didn't exist in ephemeral storage)public int queueSize()
public int ephemeralSize()
Note: ephemeral storage implementation is optional, depends on implementation.
ephemeralSize in interface IQueueCopyright © 2015 DDTH. All Rights Reserved.