Getting Started with Dyno Queues

Dyno-Queue is an interesting queue solution on top of Dynomite. Dyno-queue uses dynomite java driver a.k.a Dyno. Dyno Queue gets all benefits from dynomite like Strong Consistency, High Availability, Stability, High Throughput and Low latency and extend to queue semantics.

I highly recommend you read Netflix post about dyno-queue.


Dyno-queue also extra benefits and properties such as:
* Distributed
* No external locks (e.g. Zookeeper locks)
* Highly concurrent
* At-least-once delivery semantics
* No strict FIFO
* Delayed queue (message is not taken out of the queue until some time in the future)
* Priorities within the shard

Setting up a Dynomite Cluster with Docker

For development and experimentation reason we will use a side project I created called: dynomite-docker which makes very easy to setup dynomite cluster. So let's get started and set up the cluster.

If you are running on a mac you need to use the script instead since is for Linux. After running $ ./ run_single 0.6.0 you will have a 3 node dynomite cluster up and run and you should see something like this on the console:

Now that we have dynomite cluster Up and Running with docker we can move next and create the dyno connection.

Setting up a Dyno Connection

In order to set up a Dyno connection, we will need to create 4 classes. There we go:

* DynoConnectionManager: Connects to Dynomite and returns a client in a Sync way.
* DynomiteNodeInfo: Pojo to represent dynomite nodes information.
* DynomiteSeedsParser: Parse String format for objects.
* TokenMapSupplierHelper: Provide topology information about the cluster.

This is generic so we could use this to connect in other clusters. For sake of simplicity, the DynoConnectionManager does not take parameters but as you can see the seeds comes from Archaius so we could change if we need.

All right now we can move one and use dyno-queues.

Using Dyno Queues

We just need 1 class in order to use dyno queue - it's pretty simple - let's go.

Alright so here we create a Dyno connection to dynomite using method and then we define a dyno-queue configuration. We need to be defined a PREFIX and local-rack which will be part of the KEY inside redis. IF you running on AWS Rack should be an AZ and local-rack means same AZ as your application is running so you can reduce latency.

Them we can create a RedisQueues object and push messages to a queue we can poll messages from the queue as well and we can ACK messages to. As you can see the API is pretty simple and cool. If you want you can get the full code on my GitHub.

Diego Pacheco

Popular posts from this blog

Cool Retro Terminal

Mocking Terraform AWS using Docker

Go and Redis running on Kubernetes with Minukube