Skip to content

A Minimal distributed queue using couchbase as storage

Notifications You must be signed in to change notification settings

ashBose/DistributedQueue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

DistributedQueue

A naive distributed queue implementation using Couchbase

[MAVEN] com.couchbase.client java-client 2.4.7

Queue is a FIFO data structure. Documents inserted first will be deleted first Front and rear pointers are the document ID

The idea is operations in Couchbase are atomic operation. It has one operation called Counter, which will create document counter. Implement a queue with two pointer rear and front. Both of them are considered as two documents with initial value is 1.

[PUSH]

When PUSH operation is called it will create a document with Auto Increment. For example documents with ID like ADJ_TXN_ID:2, ADJ_TXN_ID:3 will be created in incremented way.

[POP]

Now with the counter operation , it will create a document with increment rear like ADJ_TXN_ID:1, POP operation will delete the document with ids which are inserted in first order, it will retrieve the value from rear Counter ID.

As operations are atomic, so it can happen in distributed environment. Couchbase will take care of the atomicity .

PUSH] --> ["queue:front"] --> New Document.

[POP] ---> [""queue:rear"] --> Delete Document

About

A Minimal distributed queue using couchbase as storage

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages