This is a general comparison of streams and queues. Implementations may vary.
Stream and queue are alike and sometimes confused because they both acts as a buffer of ordered data, but they differ significantly otherwise.
|Type||Continuous data||Discrete data|
|Useful Unit||A series of data||Individual data|
|Data Storage||Remain in stream until expired||Deleted manually after processing|
|Cursor||Using multiple cursors to read data from different positions||No cursor, everyone reads from same position (FILO or FIFO)|
|Data Hiding||No data hiding, after processing you set a new cursor and move on||Hides data for a brief period to prevent multiple workers processing the same data|
Notable Use Cases
For stream, individual data do not make sense. For example, bank doing stats over a period of data, or video processing.
Single bits and bytes, a single transaction do not contribute much to the ends. Only when millions of transactions are processed then we have a useful result. When processing video we wait at least one more more frames are fetched from the stream to begin processing. Data flows continuously. Tiny bits of data in stream could be lost / duplicated without causing much trouble.
For queues, individual data makes all the difference. No matter it is a user transaction, login, or other business record, every single unit of data has a complete meaning and must be processed.
Though we could still batch processing multiple pieces of data at once, we processes then one by one, not as a whole as compared to streams.
Data in queues is usually important so duplication, lost data must be compensated and treated with care.