protected Collection<? extends IQueueMessage<ID, DATA>> _getOrphanMessagesWithRetries(
            long thresholdTimestampMs, Connection conn, int numRetries, int maxRetries) {
        try {
            jdbcHelper.startTransaction(conn);
            conn.setTransactionIsolation(transactionIsolationLevel);
            Collection<? extends IQueueMessage<ID, DATA>> msgs = getOrphanFromEphemeralStorage(conn,
                    thresholdTimestampMs);
            jdbcHelper.commitTransaction(conn);
            return msgs;
        } catch (DaoException de) {
            if (de.getCause() instanceof ConcurrencyFailureException) {
                jdbcHelper.rollbackTransaction(conn);
                if (numRetries > maxRetries) {
                    throw new QueueException(de);
                } else {
                    incRetryCounter("_getOrphanMessagesWithRetries");
                    return _getOrphanMessagesWithRetries(thresholdTimestampMs, conn, numRetries + 1,
                            maxRetries);
                }
            }
            throw de;
        } catch (Exception e) {
            jdbcHelper.rollbackTransaction(conn);
            throw e instanceof QueueException ? (QueueException) e : new QueueException(e);
        }
    }
protected Collection < ? extends IQueueMessage < ID , DATA > > _getOrphanMessagesWithRetries ( long thresholdTimestampMs , Connection conn , int numRetries , int maxRetries ) { try { jdbcHelper . startTransaction ( conn ) ; conn . setTransactionIsolation ( transactionIsolationLevel ) ; Collection < ? extends IQueueMessage < ID , DATA > > msgs = getOrphanFromEphemeralStorage ( conn , thresholdTimestampMs ) ; jdbcHelper . commitTransaction ( conn ) ; return msgs ; } catch ( DaoException de ) { if ( de . getCause ( ) instanceof ConcurrencyFailureException ) { jdbcHelper . rollbackTransaction ( conn ) ; if ( numRetries > maxRetries ) { throw new QueueException ( de ) ; } else { incRetryCounter ( "_getOrphanMessagesWithRetries" ) ; return _getOrphanMessagesWithRetries ( thresholdTimestampMs , conn , numRetries + 1 , maxRetries ) ; } } throw de ; } catch ( Exception e ) { jdbcHelper . rollbackTransaction ( conn ) ; throw e instanceof QueueException ? ( QueueException ) e : new QueueException ( e ) ; } }
Get all orphan messages (messages that were left in ephemeral storage for
a long time), retry if deadlock.

<p>
Note: http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
</p>
<p>
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.
</p>

@param thresholdTimestampMs
@param conn
@param numRetries
@param maxRetries
@return
@since 0.2.0