Hi Sasikala, Can you share your full code snippet. I hope you have initially set connection autoCommit value to false. As Lahiru mentioned, it would be best to have foreign key constraint with cascade delete.
Thanks, Harsha On Wed, May 27, 2015 at 10:20 AM, Sasikala Kottegoda <sasik...@wso2.com> wrote: > Hi all, > > MB stores message metadata and content in two separate tables. > > Currently, message metadata is being deleted once the messages are > delivered, but the content is not (deleted later by a scheduled task). > > What I'm trying to do is to delete (transactional delete) both message > metadata and content once they get delivered. For this, I have created two > prepared statements. I add messages to these two statements and execute the > batches as shown below. > > for (AndesRemovableMetadata md : messagesToRemove) { > //add parameters to delete metadata > metadataRemovalPreparedStatement.setInt(1, queueID); > metadataRemovalPreparedStatement.setLong(2, md.getMessageID()); > metadataRemovalPreparedStatement.addBatch(); > > //add parameters to delete content > contentRemovalPreparedStatment.setLong(1, md.getMessageID()); > contentRemovalPreparedStatment.addBatch(); > } > metadataRemovalPreparedStatement.executeBatch(); > contentRemovalPreparedStatment.executeBatch(); > connection.commit(); > > > This works fine in a normal scenario. But when I kill the MB node (which > acts as the SQL client) suddenly, it seems like the execution of the second > prepared statement is not completed. Meaning that, even though the metadata > is removed from the respective table, the content is not. When I > interchange the statement executions, metadata gets left in the metadata > table and content gets deleted. > > Could I please know what I'm doing wrong? > > Also, another solution to this would be to add a foreign key constraint to > the content table to enable cascade delete. Would that be a better approach? > > Thank you > -- > Sasikala Kottegoda > *Software Engineer* > WSO2 Inc., http://wso2.com/ > lean. enterprise. middleware > Mobile: +94 774835928/712792401 > > _______________________________________________ > Dev mailing list > Dev@wso2.org > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Harsha Kumara Software Engineer, WSO2 Inc. Mobile: +94775505618 Blog:harshcreationz.blogspot.com
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev