modules/andes-core/broker/src/main/java/org/wso2/andes/store/rdbms/RDBMSMessageStoreImpl.java
private void fillContentFromStorage(LongArrayList messageIDList,
            LongObjectHashMap<List<AndesMessagePart>> contentList) throws AndesException {
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        Context contextRead = MetricManager.timer(MetricsConstants.DB_READ, Level.INFO).start();

        try {
            connection = getConnection();
            preparedStatement = connection.prepareStatement(getSelectContentPreparedStmt(messageIDList.size()));
            for (int mesageIDCounter = 0; mesageIDCounter < messageIDList.size(); mesageIDCounter++) {
                preparedStatement.setLong(mesageIDCounter + 1, messageIDList.get(mesageIDCounter));
            }

            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                long messageID = resultSet.getLong(MESSAGE_ID);
                int offset = resultSet.getInt(MSG_OFFSET);
                List<AndesMessagePart> partList = contentList.get(messageID);
                if (null == partList) {
                    partList = new ArrayList<>();
                    contentList.put(messageID, partList);
                }
                AndesMessagePart msgPart = createMessagePart(resultSet, messageID, offset);
                partList.add(msgPart);
            }
            connection.commit();
        } catch (SQLException e) {
            rollback(connection, TASK_RETRIEVING_CONTENT_FOR_MESSAGES);
            throw rdbmsStoreUtils.convertSQLException("Error occurred while retrieving message content from DB for " +
                    messageIDList.size() + " messages ", e);
        } finally {
            contextRead.stop();
            close(connection, preparedStatement, resultSet, TASK_RETRIEVING_CONTENT_FOR_MESSAGES);
        }
    }
/**
     * Utility method to retrieve content given the list of messages Ids.
     *
     * @param messageIDList message ids
     * @param contentList   this list will be filled with content retrieved from database
     * @throws AndesException an error
     */
Utility method to retrieve content given the list of messages Ids.
@param messageIDList message ids
@param contentList   this list will be filled with content retrieved from database
@throws AndesException an error
Utility method to retrieve content given the list of messages Ids . @param messageIDList message ids @param contentList this list will be filled with content retrieved from database @throws AndesException an error
private void fillContentFromStorage(LongArrayList messageIDList,
            LongObjectHashMap<List<AndesMessagePart>> contentList) throws AndesException {
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        Context contextRead = MetricManager.timer(MetricsConstants.DB_READ, Level.INFO).start();
        try {
            connection = getConnection();
            preparedStatement = connection.prepareStatement(getSelectContentPreparedStmt(messageIDList.size()));
            for (int mesageIDCounter = 0; mesageIDCounter < messageIDList.size(); mesageIDCounter++) {
                preparedStatement.setLong(mesageIDCounter + 1, messageIDList.get(mesageIDCounter));
            }
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                long messageID = resultSet.getLong(MESSAGE_ID);
                int offset = resultSet.getInt(MSG_OFFSET);
                List<AndesMessagePart> partList = contentList.get(messageID);
                if (null == partList) {
                    partList = new ArrayList<>();
                    contentList.put(messageID, partList);
                }
                AndesMessagePart msgPart = createMessagePart(resultSet, messageID, offset);
                partList.add(msgPart);
            }
            connection.commit();
        } catch (SQLException e) {
            rollback(connection, TASK_RETRIEVING_CONTENT_FOR_MESSAGES);
            throw rdbmsStoreUtils.convertSQLException("Error occurred while retrieving message content from DB for " +
                    messageIDList.size() + " messages ", e);
        } finally {
            contextRead.stop();
            close(connection, preparedStatement, resultSet, TASK_RETRIEVING_CONTENT_FOR_MESSAGES);
        }
    }
private void fillContentFromStorage ( LongArrayList messageIDList , LongObjectHashMap < List < AndesMessagePart > > contentList ) throws AndesException { Connection connection = null ; PreparedStatement preparedStatement = null ; ResultSet resultSet = null ; Context contextRead = MetricManager . timer ( MetricsConstants . DB_READ , Level . INFO ) . start ( ) ; try { connection = getConnection ( ) ; preparedStatement = connection . prepareStatement ( getSelectContentPreparedStmt ( messageIDList . size ( ) ) ) ; for ( int mesageIDCounter = 0 ; mesageIDCounter < messageIDList . size ( ) ; mesageIDCounter ++ ) { preparedStatement . setLong ( mesageIDCounter + 1 , messageIDList . get ( mesageIDCounter ) ) ; } resultSet = preparedStatement . executeQuery ( ) ; while ( resultSet . next ( ) ) { long messageID = resultSet . getLong ( MESSAGE_ID ) ; int offset = resultSet . getInt ( MSG_OFFSET ) ; List < AndesMessagePart > partList = contentList . get ( messageID ) ; if ( null == partList ) { partList = new ArrayList < > ( ) ; contentList . put ( messageID , partList ) ; } AndesMessagePart msgPart = createMessagePart ( resultSet , messageID , offset ) ; partList . add ( msgPart ) ; } connection . commit ( ) ; } catch ( SQLException e ) { rollback ( connection , TASK_RETRIEVING_CONTENT_FOR_MESSAGES ) ; throw rdbmsStoreUtils . convertSQLException ( "Error occurred while retrieving message content from DB for " + messageIDList . size ( ) + " messages " , e ) ; } finally { contextRead . stop ( ) ; close ( connection , preparedStatement , resultSet , TASK_RETRIEVING_CONTENT_FOR_MESSAGES ) ; } }
Utility method to retrieve content given the list of messages Ids.
Utility method to retrieve content given the list of messages Ids .