Deep-dive on the Next Gen Platform. Join the Webinar!

Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Add-ons
  • All Add-ons
  • IronMQ Message Queue as a Service
IronMQ Message Queue as a Service

This add-on is operated by Iron.io

Serverless, High Performance, Lightning Fast Message Queue

IronMQ Message Queue as a Service

Last updated July 12, 2023

Table of Contents

  • IronMQ Setup on Heroku
  • Language support
  • Ruby
  • Java
  • Python
  • Clojure
  • Node.js
  • Next steps
  • Support

IronMQ is a massively scalable, hosted message queue. It makes managing data and event flow within your application simple, with support for multiple clients and a managed environment that frees you from needing to manage servers, allowing you to focus on your application instead.

IronMQ Setup on Heroku

1) Install the IronMQ addon for Heroku

$ heroku addons:create iron_mq:developer
-----> Adding iron_mq to cold-winter-5462... done, v10 (free)

2) Install the IronMQ client library (Ruby Example)

$ gem install iron_mq

3) Configuration: retrieve Token and Project ID

$ heroku config | grep IRON
IRON_WORKER_PROJECT_ID => 123456789
IRON_WORKER_TOKEN      => aslkdjflaksuilaks

4) Use the installed client lib to interact with your queues (create a queue, post/get/delete a message, etc.). Client lib is a wrapper over the rest api. Below you can find examples for different programming languages.

Language support

IronMQ has clients for a lot of languages, and you can always use the REST API (or write your own!). This means your existing Heroku stack should work without any changes.

Ruby

We’re going to need to install the Ruby gem, for development purposes:

$ gem install iron_mq
Fetching: iron_mq-3.0.2.gem (100%)
Successfully installed iron_mq-3.0.2

If you’re building for a Rails application or anything that uses Bundler, add the following to your Gemfile:

gem 'iron_mq'

Now you have a simple helper that allows you to interact with your queues:

# Create an IronMQ::Client object
@ironmq = IronMQ::Client.new()

# Get a queue (if it doesn't exist, it will be created when you first post a message)
@queue = @ironmq.queue("my_queue")

# Post a message
@queue.post("hello world!")

# Get a message
msg = @queue.get()
p msg

# Delete a message (you must delete a message when you're done with it or it will go back on the queue after a timeout)
msg.delete # or @queue.delete(msg.id)

Java

You can use Maven to install the official IronMQ Java library or download the jar file. More details are here.

Once you have the jar file added as a dependency, you have a simple wrapper that allows you to interact with your queues:

import io.iron.ironmq.*;
...

// Get your Iron.io credentials from the environment
Map<String, String> env = System.getenv();

// Create a Client object
Client client = new Client(env.get("IRON_MQ_PROJECT_ID"), env.get("IRON_MQ_TOKEN"), Cloud.IronAWSUSEast);

// Get a queue (if it doesn't exist, it will be created when you first post a message)
Queue queue = client.queue("my_queue");

// Post a message
queue.Push("hello world!");

// Get a message
Message msg = queue.get();
System.out.println(msg.getBody());

// Delete a message (you must delete a message when you're done with it or it will go back on the queue after a timeout)
queue.deleteMessage(msg);

Python

We’re going to have to install the Python client library for IronMQ. You can do this using pip install iron_mq or easy_install iron_mq.

Once the package is installed, you have a simple wrapper that allows you to interact with your queues:

# Create an IronMQ client object
mq = IronMQ()

# Get a queue (if it doesn't exist, it will be created when you first post a message)
queue = mq.queue("my_queue")

# Post a message
queue.post("hello world!")

# Get a message
msg = queue.get()
print msg

# Delete a message (you must delete a message when you're done with it or it will go back on the queue after a timeout)
queue.delete(msg["messages"][0]["id"])

Clojure

We’re going to need to add the IronMQ Clojure client to your project.clj:

[iron_mq_clojure "1.0.3"]

Use these to create a client that allows you to interact with your queues:

(require '[iron-mq-clojure.client :as mq])

(def client (mq/create-client (System/getenv "IRON_MQ_TOKEN") (System/getenv "IRON_MQ_PROJECT_ID")))

; Post a message
(mq/post-message client "my_queue" "Hello world!")

; Get a message
(let [msg (mq/get-message client "my_queue")]
  (println (get msg "body"))

  ; Delete a message (you must delete a message when you're done with it or it will go back on the queue after a timeout)
  (mq/delete-message client "my_queue" msg))

Node.js

We’re going to need to the IronMQ Node.js client to interact with our queues. You can get it using npm install iron_mq or by downloading the source from Github (though you’ll need iron_core_node, too).

Once that’s done, you can require it to get a simple wrapper for the API:

var iron_mq = require("iron_mq");

var client = new iron_mq.Client({"queue_name": "my_queue"});

// Post a message
client.post("test message", function(error, body) {
  console.log(body);
  console.log(error);
});

// Get a message
client.get({}, function(error, body) {
  console.log(error);
  console.log(body);
  if(error == null) {
    // Delete a message
    client.del(body["id"], function(error, body) {
      console.log(error);
      console.log(body);
    });
  }
});

Next steps

To get into more advanced uses of IronMQ, you may want to check out the API docs or check out an example Sinatra application that ties in IronWorker at https://github.com/iron-io/heroku_sinatra_example.

Support

Issues should get logged with Heroku Support. You can also find more resources at the Iron.io Dev Center.

Keep reading

  • All Add-ons

Feedback

Log in to submit feedback.

Zara 4 IronWorker Job Workers As A Service

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices