Download the PHP package iron-io/iron_mq without Composer
On this page you can find all versions of the php package iron-io/iron_mq. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iron-io/iron_mq
More information about iron-io/iron_mq
Files in iron-io/iron_mq
Package iron_mq
Short Description Client binding for IronMQ (hosted message queue)
License MIT
Homepage http://github.com/iron-io/iron_mq_php
Informations about the package iron_mq
IronMQ v4 PHP Client Library
IronMQ is an elastic message queue for managing data and event flow within cloud applications and between systems.
This library uses IronMQ API v3.
Branches
*If you're using laravel and see "Class IronMQ not found"
error set iron_mq
version to `1.` and install/update dependencies**
1.*
- Laravel 4.0/4.1/4.2/5.0 compatible, PHP 5.2 compatible version. No namespaces. Using IronMQv2 servers (deprecated).2.*
- Laravel 5.1/5.2 compatible, PSR-4 compatible version. With namespaces. Using IronMQv2 servers (deprecated).3.*
- Laravel 4.0/4.1/4.2/5.0 compatible, PHP 5.2 compatible version. IronMQv3.4.*
- (recommended) Laravel 5.1/5.2 compatible, PSR-4 compatible version. With namespaces. IronMQv3. Current default.master
branch - same as4.*
Update notes
- 1.3.0 - changed argument list in methods
postMessage
andpostMessages
. Please revise code that uses these methods. - 1.4.5 - added
getMessagePushStatuses
anddeleteMessagePushStatus
methods. - 2.0.0 - version 2.0 introduced some backward incompatible changes. IronMQ client finally PSR-4 compatible and using namespaces & other php 5.3 stuff. If you're migrating from previous (1.x) version, please carefully check how iron_mq / iron_core classes loaded.
If you need some 1.x features like
.phar
archives, use latest 1.x stable version: https://github.com/iron-io/iron_mq_php/releases/tag/1.5.3
Getting Started
Get credentials
To start using iron_mq_php, you need to sign up and get an oauth token.
- Go to http://iron.io/ and sign up.
- Get an Oauth Token at http://hud.iron.io/tokens
--
Install iron_mq_php
There are two ways to use iron_mq_php:
Using composer
Create composer.json
file in project directory:
Do composer install
(install it if needed: https://getcomposer.org/download/)
And use it:
Using classes directly (strongly not recommended)
- Copy classes from
src
to target directory - Grab IronCore classes there and copy to target directory
- Include them all.
--
Configure
Three ways to configure IronMQ:
-
Passing array with options:
-
Passing ini file name which stores your configuration options. Rename sample_config.ini to config.ini and include your Iron.io credentials (
token
andproject_id
): -
Automatic config search - pass zero arguments to constructor and library will try to find config file in following locations:
iron.ini
in current directoryiron.json
in current directoryIRON_MQ_TOKEN
,IRON_MQ_PROJECT_ID
and other environment variablesIRON_TOKEN
,IRON_PROJECT_ID
and other environment variables.iron.ini
in user's home directory.iron.json
in user's home directory
--
Keystone Authentication
Via Configuration File
Add keystone
section to your iron.json file:
In Code
The Basics
Post a Message to the Queue
More complex example:
Post multiple messages in one API call:
--
Reserve a Message
When you pop/get a message from the queue, it will NOT be deleted. It will eventually go back onto the queue after a timeout if you don't delete it (default timeout is 60 seconds).
Reserve multiple messages in one API call:
Reservation Id is needed for operations like delete, touch or release a message. It could be obtained from message model after reserving it:
--
Delete a Message from the Queue
If message isn't reserved, you don't need to provide reservation id
Delete a message from the queue when you're done with it.
Delete multiple messages in one API call:
Delete multiple messages specified by messages id array.
It's also possible to delete array of message objects:
--
Troubleshooting
http error: 0
If you see Uncaught exception 'Http_Exception' with message 'http error: 0 | '
it most likely caused by misconfigured cURL https sertificates.
There are two ways to fix this error:
- Disable SSL sertificate verification - add this line after IronMQ initialization:
$ironmq->ssl_verifypeer = false;
- Switch to http protocol - add this to configuration options:
protocol = http
andport = 80
- Fix the error! Recommended solution: download actual certificates - cacert.pem and add them to
php.ini
:
--
Updating notes
- 1.3.0 - changed argument list in methods
postMessage
andpostMessages
. Please revise code that uses these methods. - 1.4.5 - added
getMessagePushStatuses
anddeleteMessagePushStatus
methods.
--
Queues
IronMQ Client
IronMQ
is based on IronCore
and provides easy access to the whole IronMQ API.
--
List Queues
This code will return first 30 queues sorted by name.
Optional parameters:
per_page
: number of elements in response, default is 30.previous
: this is the last queue on the previous page, it will start from the next one. If queue with specified name doesn’t exist result will contain first per_page queues that lexicographically greater than previous
Assume you have queues named "a", "b", "c", "d", "e". The following code will list "c", "d" and "e" queues:
--
Retrieve Queue Information
--
Delete a Message Queue
--
Post Messages to a Queue
Single message:
Multiple messages:
Optional parameters (3rd, array
of key-value pairs):
-
delay
: The item will not be available on the queue until this many seconds have passed. Default is 0 seconds. Maximum is 604,800 seconds (7 days). -
expires_in
: How long in seconds to keep the item on the queue before it is deleted. Default is 604,800 seconds (7 days). Maximum is 2,592,000 seconds (30 days). : Deprecated. Can no longer set timeout when posting a message, only when reserving one.timeout
--
Get Messages from a Queue
Single message:
Multiple messages:
Optional parameters:
-
$count
: The maximum number of messages to get. Default is 1. Maximum is 100. -
$timeout
: After timeout (in seconds), item will be placed back onto queue. You must delete the message from the queue to ensure it does not go back onto the queue. If not set, value from POST is used. Default is 60 seconds. Minimum is 30 seconds. Maximum is 86,400 seconds (24 hours). $wait
: Time to long poll for messages, in seconds. Max is 30 seconds. Default 0.
--
Touch a Message on a Queue
Touching a reserved message returns new reservation with specified or default timeout.
--
Release Message
Parameters:
$delay
: The item will not be available on the queue until this many seconds have passed. Default is 0 seconds. Maximum is 604,800 seconds (7 days).
--
Delete a Message from a Queue
--
Peek Messages from a Queue
Peeking at a queue returns the next messages on the queue, but it does not reserve them.
Single message:
Multiple messages:
--
Clear a Queue
--
Push Queues
IronMQ push queues allow you to setup a queue that will push to an endpoint, rather than having to poll the endpoint. Here's the announcement for an overview.
Create a Queue
Options:
type
: String or symbol. Queue type.:pull
,:multicast
,:unicast
. Field required and static.message_timeout
: Integer. Number of seconds before message back to queue if it will not be deleted or touched.message_expiration
: Integer. Number of seconds between message post to queue and before message will be expired.
The following parameters are all related to Push Queues:
push: subscribers
: An array of subscriber hashes containing aname
and aurl
required fields, and optionalheaders
hash.headers
's keys are names and values are means of HTTP headers. This set of subscribers will replace the existing subscribers. To add or remove subscribers, see the add subscribers endpoint or the remove subscribers endpoint. See below for example json.push: retries
: How many times to retry on failure. Default is 3. Maximum is 100.push: retries_delay
: Delay between each retry in seconds. Default is 60.push: error_queue
: String. Queue name to post push errors to.
--
Update Queue Information
Same as create queue. A push queue couldn't be changed into a pull queue, so vice versa too.
Add/Remove Subscribers on a Queue
Add subscribers to Push Queue:
--
Replace Subscribers on a Queue
Sets list of subscribers to a queue. Older subscribers will be removed.
Remove Subscribers from a Queue
Remove subscriber from a queue. This is for Push Queues only.
Get Message Push Status
Returns an array of subscribers with status.
--
Acknowledge, That Push Message Is Processed
This method could be used to acknowledgement process of push messages. See IronMQ v3 documentation on long-processing for further information.
--
Further Links
© 2011 - 2013 Iron.io Inc. All Rights Reserved.