Right on Queue: Message Queues Made Simple

Right on Queue: Message Queues Made Simple with Iron.io

All apps have a range of tasks that they perform for their end users, whether the user is aware of this or not. These might include processing images, collecting data, or an email service response when a user inputs their details or subscribes. Message queues can even collate data and analytics for your CRM or link to your Salesforce.

Apps can, of course, have all this functionality built right into the main logic. However, as more and more resource is required to deal with increasing numbers of users, those users will certainly start to notice latency and lag, and will inevitably stop using the app and go elsewhere.

Enter background tasks, run by intelligently-coded workers, that take a workload away from the app and use message queues to decide what tasks need doing and when.

Talk to Iron.io about maximizing your app development with the fastest MQ.

Give Iron.io a try with a free trial and experience everything Iron.io can do

Achieve Cloud Elasticity with Iron

Speak to us to find how you can achieve cloud elasticity with a serverless messaging queue and background task solution with free handheld support.

Message Queues: How do they Work?

Message queues allow tasks to be queued up in such a way that they’re dealt with as and when they need to be. Effective queues are persistent, meaning that the instruction to deal with the task doesn’t leave the queue until there is acknowledgment from the task handler that the task has been dealt with, either in real-time or on a schedule.

Your app sends a user request as code, possibly XML or JSON. These requests are dealt with by scripts. Sometimes, Cron jobs are used to schedule tasks or deal with automation. Once the relevant scripts have dealt with or scheduled relevant tasks, that task is removed from the queue. Message queues are asynchronous, meaning tasks are dealt with by the backend at the time they need to be, rather than the end-user having to wait for a response.

Message queues can use Secure Socket Layer (SSL) for additional security. Providers of MQs include Iron.io, Redis, SendGrid, Oracle, plus messaging services can be created using open source languages like PHP, Java, or Python.

Pub/Sub is an MQ service that deals with a publisher sending messages out to services or endpoints that subscribe to those messages. Only when a subscriber confirms those messages does the message stop being sent. Many systems support pub/sub or MQ within their API.

Using workers to deal with messages takes weight away from your application, leaving it light and easy to use, while workers and MQs together automate and schedule tasks accordingly.


We know developers need elasticity and scalability. Let us show you how we can help with a free demo.

Iron.io Serverless Tools

Speak to us to learn how IronWorker and IronMQ are essential products for your application to become cloud elastic.

Writing and Retrieving Your Messages

There are plenty of MQ options running on cloud services, but the following uses the HP Cloud Message Service plus cURL, a free-of-charge command-line tool that uses URL syntax for data transfer. Look for MQ tutorials and templates on how to configure in resources such as GitHub.

Create Your New Queue

curl -X PUT \

-H "X-Auth-Token: HPAuth_4f4fcc24e4b04e2d592e7d79" \

-H "Content-Type: application/json" \


This PUT request creates a new MQ called my_queue. Always look out for a common response code when sending requests. The response code here would be 201-created and would look like this:

HTTP/1.1 201 Created

Date: Tue, 23 Jul 2013 15:45:09 GMT

Location: /v1.1/1234567890/queues/my_new_queue

Writing Messages to the Queue

Use POST to send messages to the queue:

curl -X POST \

-H "X-Auth-Token: HPAuth_4f4fcc24e4b04e2d592e7d79" \

-H "Accept: application/json" \

-H "Content-Type: application/json" \

-d '{"task": "import_checkins", "foursquare_id": "5434534"}' \


Although we’re passing the same authentication headings, this goes to the messages endpoint of my_queue. The JSON message packet defines the task that needs to be completed, import­_checkins, plus the ID to associate with that task.

Retrieving Tasks from the Queue

We’re looking at a service that imports data from Foursquare about check-ins. The service then uses this data to send users a daily digest email. A CRON job running on a 24-hour basis sets a call to a script titled import_checkins.rb. That script knows to take any tasks from the MQ marked as import_checkins and retrieve the specified data.

Here’s a GET request for this:

curl -X GET \

-H "X-Auth-Token: HPAuth_4f4fcc24e4b04e2d592e7d79" \

-H "Accept: application/json" \

-H "Content-Type: application/json" \


Pending messages would prompt the following response:

HTTP/1.1 200 OK

Content-Type: application/json

Date: Tue, 23 Jul 2013 16:01:32 GMT


“id”: “1”,

“task”: “import_checkins”,

“foursquare_id”: “5434534”


The script loops through any returned messages until all tasks are complete. An efficient MQ then removes processed messages from the queue, leaving the latest message to be dealt with next. Some queues require a manual delete request to process this last step.

Right on Queue: Message Queues Made Simple with Iron.io

Uses with IronMQ

For ultimate performance, you need unlimited scalability for your apps. That means workers and message queues that are agile, adaptable, and that have functionality with a range of operating systems such as Microsoft Windows and Ubuntu Linux. IronMQ is one of the fastest message queues available for app developers. Faster than competitors like RabbitMQ, IronMQ can run as an MQ as a service, is highly elastic, and always persistent, preventing data loss and task duplication.

Use Iron MQ for:

·        Daily digest emails

·        Job listings

·        Events notifications

Events as messages can be stored like so:

curl -X POST \

-H "X-Auth-Token: HPAuth_4f4fcc24e4b04e2d592e7d79" \

-H "Accept: application/json" \

-H "Content-Type: application/json" \

-d '{"email":"foo@bar.com","timestamp":1322000095,"unique_arg":"my unique arg","event":"delivered"}' \


Using MQs in this way is less process-intensive and moves longer or low priority tasks away from affecting the core performance of your app – making for the best possible user experience.

Talk to Iron.io today and ask for a demo and see how our MQ and Worker as a Service can optimize your app development.

Unlock the Cloud with Iron.io

Find out how IronWorker and IronMQ can help your application obtain the cloud with fanatical customer support, reliable performance, and competitive pricing.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.