IronMQ

Page last updated:

IronMQ is a reliable message queue service that lets you connect systems and build distributed apps that scale effortlessly and eliminate any single points of failure.

Managing Services

To create and bind a service instance, see Managing services from the command line.

Using Service Instances with your Application

See Delivering Service Credentials to an Application and VCAP_SERVICES Environment Variable.

Format of credentials in VCAP_SERVICES environment variable:

{
   ironmq: [
      {
         name: "ironmq",
         label: "ironmq",
         tags: [ ],
         plan: "small",
         credentials: {
            project_id: "52fc1f640738fa0009000007",
            token: "wskYhifzt1Nl2XjwhGAZ0jfXLDo"
         }
      }
   ]
}

Language Support

IronMQ has clients for a lot of languages, and you can always use the REST API (or write your own!).

Ruby

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

$ gem install iron_mq

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

We’re going to need to install the jar file for the official IronMQ Java library. If you’re using Maven, you can also add the http://iron-io.github.com/maven/repository repository as a dependency.

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


// Get your Iron.io credentials from the environment
Map 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]9, 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

Support

You’re also welcome to stop by the Iron.io support chat room and chat with Iron.io staff about issues. You can also find more resources at the Iron.io Dev Center.

Integrations

Dashboard (HUD)

You can view and analyze all your queues from the HUD…

ironworkers on the hud

View analytics and gain insight about your queues

ironmq analytics

Share your projects with other people

Each of your projects can be shared with coworkers and friends. It’s easy and just takes a few seconds. They’ll get an invite to signup for Iron.io for free and have automatic access to the project once completed. Sharing your Iron Worker Project

Create a pull request or raise an issue on the source for this page in GitHub