private boolean deleteOldOfflineMessagesFromDB() {

        Log.info("Offline message cleaning - Deleting offline messages older than {} days.", OFFLINE_AUTOCLEAN_DAYSTOLIVE.getValue().toDays());

        Connection con = null;

        PreparedStatement pstmt = null;
        try {
            con = DbConnectionManager.getConnection();

            pstmt = con.prepareStatement(DELETE_OFFLINE_MESSAGE_BEFORE);

            final Instant pastTime = Instant.now().minus(OFFLINE_AUTOCLEAN_DAYSTOLIVE.getValue());
            final String creationDatePast = StringUtils.zeroPadString(String.valueOf(pastTime.toEpochMilli()), 15);

            pstmt.setString(1,creationDatePast);
            final int updateCount = pstmt.executeUpdate();
            Log.info("Offline message cleaning - Cleaning successful. Removed {} message(s)", updateCount);
            return true;
        } catch (SQLException sqle) {
            Log.warn("Offline message cleaning - ", sqle);
            return false;
        } finally {
            DbConnectionManager.closeConnection(pstmt, con);
        }
    }
Decide whether a message should be stored offline according to XEP-0160 and XEP-0334.

@param message The message to evaluate. Cannot be null.
@return <code>true</code> if the message should be stored offline, <code>false</code> otherwise.
xmppserver/src/main/java/org/jivesoftware/openfire/OfflineMessageStore.java