Queuing It Up With Flybase Simple Queues

Queues are handy for processing items in the background, you just send an item to the queue and have a worker in the background to do something with it and remove it from the queue. You can even have multiple workers running

Flybase is great for setting up queues, but we wanted to make it even better (and simpler) so we built our Queue system.

Adding items to a queue is simple, you just have to use the enqueue function, available in our latest javascript and node libraries:

const ref = new Flybase("YOUR-FLYBASE-APIKEY-OR-TOKEN", "web", "posts"); ref.enqueue({ username: 'Joe', message: 'Hello', published: new Date().getTime() });

Then to get items out of a queue, you just dequeue it:

const ref = new Flybase("YOUR-FLYBASE-APIKEY-OR-TOKEN", "web", "posts");

The getLength function returns a count of pending tasks in your queue, Then the dequeue function returns the next item in your queue.  If there are no pending jobs, then it just performs another check to see.

You could run the worker portion of your tasks in a backend node.js app, while the enqueue portion can be handled from anywhere, even direct from the browser.

RESTful Queues#

You can also use our REST API to enqueue and dequeue items:

curl -X GET -H "X-Flybase-API-Key: YOUR-FLYBASE-APIKEY-OR-TOKEN" \ https://api.flybase.io/queue/web

Will return the next item in the queue.

curl -X GET -H "X-Flybase-API-Key: YOUR-FLYBASE-APIKEY-OR-TOKEN" \ https://api.flybase.io/queue/web/count

Will return the number of pending jobs currently in the queue.

And finally:

curl -X POST -d '{ "username": "baileys", "date_of_birth": "June 9, 1978", "full_name": "Bailey Stringer"}' \ -H "X-Flybase-API-Key: YOUR-FLYBASE-APIKEY-OR-TOKEN" \ https://api.flybase.io/queue/web

will store a new task to our queue for your Flybase app called web

Queued items are removed from the queue once retrieved either via the Javascript library or from the REST API. We’ve kept our queue system simple to jump into and use, and you can have as many workers working as you want.

There are various ways you can use the queue system, and we’ve kept it as simple as possible on purpose, we don’t want to overcomplicate something as simple as queues.

Ready To Build Awesome Apps?

Get started for free

Get started

What We Do

Our BlogFeaturesPricing

© Copyright 2015-2022. Flybase by Data McFly (1059105 B.C. LTD)

Privacy Policy - Terms of Service - Service Level Agreement - Data Processing Policy