Cassandra solution to queue anti-pattern

Viewed 111

I have a message queue table, with messages that are sent from user A to user B, but not yet read by user B. After user B reads a message, it gets transferred from queue table to history table. (delete, insert) As I understood queue table represents an anti-pattern.

What is the right way to approach this problem? Having just one table with additional column like (ReadStatus)? But then we run into problems related to partition keys (queue partition key is enough - ReceiverId & history partition key should be - (SenderId, ReceiverId)).

1 Answers

You are right in knowing that Cassandra is not a good fit with queue datasets.

There's a way of modeling your data so you it doesn't suffer from having to iterate over tombstones (deleted or expired rows) by grouping data into tables and then truncating the table when you're done processing the data.

I learnt the technique from Ryan Svihla's blog post, Understanding deletes. Cheers!

Related