modules/andes-core/broker/src/main/java/org/wso2/andes/store/rdbms/RDBMSMessageStoreImpl.java
void prepareToDeleteMessages(Connection connection, Collection<? extends AndesMessageMetadata> messagesToRemove)
            throws AndesException, SQLException {

        PreparedStatement metadataRemovalPreparedStatement = null;
        PreparedStatement contentRemovalPreparedStatement = null;
        PreparedStatement expirationDataRemovalPreparedStatement = null;

        try {
            LongArrayList messageIDsToRemoveFromCache = new LongArrayList();
            metadataRemovalPreparedStatement = connection.prepareStatement(RDBMSConstants.PS_DELETE_METADATA);
            contentRemovalPreparedStatement = connection.prepareStatement(RDBMSConstants.PS_DELETE_CONTENT);
            expirationDataRemovalPreparedStatement = connection.prepareStatement(RDBMSConstants.PS_DELETE_EXPIRATION_DATA);

            for (AndesMessageMetadata message : messagesToRemove) {
                //add parameters to delete metadata
                messageIDsToRemoveFromCache.add(message.getMessageID());
                metadataRemovalPreparedStatement.setLong(1, message.getMessageID());
                metadataRemovalPreparedStatement.addBatch();
                contentRemovalPreparedStatement.setLong(1, message.getMessageID());
                contentRemovalPreparedStatement.addBatch();
                expirationDataRemovalPreparedStatement.setLong(1, message.getMessageID());
                expirationDataRemovalPreparedStatement.addBatch();
            }

            removeFromCache(messageIDsToRemoveFromCache);
            // First remove content and then metadata to avoid foreign key constraints.
            contentRemovalPreparedStatement.executeBatch();
            expirationDataRemovalPreparedStatement.executeBatch();
            metadataRemovalPreparedStatement.executeBatch();
        } finally {
            close(contentRemovalPreparedStatement, TASK_DELETING_METADATA);
            close(expirationDataRemovalPreparedStatement, TASK_DELETING_METADATA);
            close(metadataRemovalPreparedStatement, TASK_DELETING_METADATA);
        }
    }
/**
     * Delete the messages from message store using the provided database {@link Connection}
     * @param connection JDBC {@link Connection}
     * @param messagesToRemove {@link Collection} of {@link AndesMessageMetadata}
     * @throws AndesException throws {@link AndesException} on JDBC driver related exception
     * @throws SQLException throws {@link SQLException} on JDBC driver related exception
     */
Delete the messages from message store using the provided database  Connection
@param connection JDBC  Connection
@param messagesToRemove  Collection of  AndesMessageMetadata
@throws AndesException throws  AndesException on JDBC driver related exception
@throws SQLException throws  SQLException on JDBC driver related exception
Delete the messages from message store using the provided database Connection @param connection JDBC Connection @param messagesToRemove Collection of AndesMessageMetadata @throws AndesException throws AndesException on JDBC driver related exception @throws SQLException throws SQLException on JDBC driver related exception
void prepareToDeleteMessages(Connection connection, Collection<? extends AndesMessageMetadata> messagesToRemove)
            throws AndesException, SQLException {
        PreparedStatement metadataRemovalPreparedStatement = null;
        PreparedStatement contentRemovalPreparedStatement = null;
        PreparedStatement expirationDataRemovalPreparedStatement = null;
        try {
            LongArrayList messageIDsToRemoveFromCache = new LongArrayList();
            metadataRemovalPreparedStatement = connection.prepareStatement(RDBMSConstants.PS_DELETE_METADATA);
            contentRemovalPreparedStatement = connection.prepareStatement(RDBMSConstants.PS_DELETE_CONTENT);
            expirationDataRemovalPreparedStatement = connection.prepareStatement(RDBMSConstants.PS_DELETE_EXPIRATION_DATA);
            for (AndesMessageMetadata message : messagesToRemove) {
                messageIDsToRemoveFromCache.add(message.getMessageID());
                metadataRemovalPreparedStatement.setLong(1, message.getMessageID());
                metadataRemovalPreparedStatement.addBatch();
                contentRemovalPreparedStatement.setLong(1, message.getMessageID());
                contentRemovalPreparedStatement.addBatch();
                expirationDataRemovalPreparedStatement.setLong(1, message.getMessageID());
                expirationDataRemovalPreparedStatement.addBatch();
            }
            removeFromCache(messageIDsToRemoveFromCache);
            contentRemovalPreparedStatement.executeBatch();
            expirationDataRemovalPreparedStatement.executeBatch();
            metadataRemovalPreparedStatement.executeBatch();
        } finally {
            close(contentRemovalPreparedStatement, TASK_DELETING_METADATA);
            close(expirationDataRemovalPreparedStatement, TASK_DELETING_METADATA);
            close(metadataRemovalPreparedStatement, TASK_DELETING_METADATA);
        }
    }
void prepareToDeleteMessages ( Connection connection , Collection < ? extends AndesMessageMetadata > messagesToRemove ) throws AndesException , SQLException { PreparedStatement metadataRemovalPreparedStatement = null ; PreparedStatement contentRemovalPreparedStatement = null ; PreparedStatement expirationDataRemovalPreparedStatement = null ; try { LongArrayList messageIDsToRemoveFromCache = new LongArrayList ( ) ; metadataRemovalPreparedStatement = connection . prepareStatement ( RDBMSConstants . PS_DELETE_METADATA ) ; contentRemovalPreparedStatement = connection . prepareStatement ( RDBMSConstants . PS_DELETE_CONTENT ) ; expirationDataRemovalPreparedStatement = connection . prepareStatement ( RDBMSConstants . PS_DELETE_EXPIRATION_DATA ) ; for ( AndesMessageMetadata message : messagesToRemove ) { messageIDsToRemoveFromCache . add ( message . getMessageID ( ) ) ; metadataRemovalPreparedStatement . setLong ( 1 , message . getMessageID ( ) ) ; metadataRemovalPreparedStatement . addBatch ( ) ; contentRemovalPreparedStatement . setLong ( 1 , message . getMessageID ( ) ) ; contentRemovalPreparedStatement . addBatch ( ) ; expirationDataRemovalPreparedStatement . setLong ( 1 , message . getMessageID ( ) ) ; expirationDataRemovalPreparedStatement . addBatch ( ) ; } removeFromCache ( messageIDsToRemoveFromCache ) ; contentRemovalPreparedStatement . executeBatch ( ) ; expirationDataRemovalPreparedStatement . executeBatch ( ) ; metadataRemovalPreparedStatement . executeBatch ( ) ; } finally { close ( contentRemovalPreparedStatement , TASK_DELETING_METADATA ) ; close ( expirationDataRemovalPreparedStatement , TASK_DELETING_METADATA ) ; close ( metadataRemovalPreparedStatement , TASK_DELETING_METADATA ) ; } }
Delete the messages from message store using the provided database {@link Connection}
 @param connection JDBC {@link Connection}
 @param messagesToRemove {@link Collection} of {@link AndesMessageMetadata}
 @throws AndesException throws {@link AndesException} on JDBC driver related exception
 @throws SQLException throws {@link SQLException} on JDBC driver related exception
Delete the messages from message store using the provided database { @link Connection } @param connection JDBC { @link Connection } @param messagesToRemove { @link Collection } of { @link AndesMessageMetadata } @throws AndesException throws { @link AndesException } on JDBC driver related exception @throws SQLException throws { @link SQLException } on JDBC driver related exception
//add parameters to delete metadata // First remove content and then metadata to avoid foreign key constraints.