A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/iron-io/iron_mq_python below:

iron-io/iron_mq_python: Python client for IronMQ.

Python language binding for IronMQ. IronMQ is an elastic message queue for managing data and event flow within cloud applications and between systems. See How It Works

To start using iron_mq_python, you need to sign up and get an OAuth2 token.

  1. Go to http://iron.io/ and sign up.
  2. Get an OAuth2 Token at http://hud.iron.io/tokens

or just copy iron_mq.py and include it in your script:

will try reasonable defaults, accepting following optionally:

ironmq = IronMQ(host='mq-aws-us-east-1-1.iron.io',
                project_id='500f7b....b0f302e9',
                token='Et1En7.....0LuW39Q',
                protocol='https', port=443,
                api_version=3,
                config_file=None)

returns list of queues names

we get queue by name:

queue = ironmq.queue('test_queue')
Push a message(s) on the queue:
queue.post('Hello world')

Message can be described by dict:

message = {
    "body" : "Test Message",
    "delay" : 5, # The item will not be available on the queue until this many seconds have passed. Defaults to 0.
}
queue.post(message)

Can no longer set timeout when posting a message, only when reserving one.

We can post several messages at once:

queue.post('more', 'and more', 'and more')
queue.post(*[str(i) for i in range(10)])
queue.reserve(max=10, timeout=None, wait=0, delete=False)

All fields are optional.

When you reserve 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).

queue.get_message_by_id('xxxxxxxx')
Delete a message from the queue:

Delete a message from the queue when you're done with it.

queue.delete(message_id, reservation_id)

Reserved message could not be deleted without reservation id.

Delete multiple messages in one API call:

ids = queue.post('more', 'and more', 'and more')['ids']
queue.delete_multiple(ids = ids);

Delete multiple messages specified by messages id.

messages = queue.reserve(3)
queue.delete_multiple(messages = messages);

Delete multiple messages specified by response after reserving messages.

queue.info()
 # {u'name': u'queue12',
 # u'project_id': u'54f95a43ecbd7e000800002a',
 # u'message_timeout': 60,
 # u'message_expiration': 604800,
 # u'size': 15,
 # u'total_messages': 17}
queue.size() # 15
queue.name
queue.total_messages() # 17

Get messages without reservation. It does not remove messages from a queue. So that, after peeking messages, they will be available to reserve or peek.

msgs = queue.peek(max=10) # {"messages": [{'id': '..', 'body': '..'}, ..]}

To extend the reservation on a reserved message, use touch. The message reservation will be extended by provided timeout seconds. If timeout is not set, current queue timeout will be used.

queue.touch(message_id, reservation_id, timeout=10)

It releases the message by its ID and reservation ID. Optional parameter delay signalise after how many seconds the message must be released.

queue.release(message_id, reservation_id, delay=30)
ironmq = IronMQ()
options = {
  'message_timeout': 120,
  'message_expiration': 24 * 3600,
  'push': {
    'subscribers': [
      {
        'name': 'subscriber_name',
        'url': 'http://rest-test.iron.io/code/200?store=key1',
        'headers': {
          'Content-Type': 'application/json'
        }
      }
    ],
    'retries': 3,
    'retries_delay': 30,
    'error_queue': 'error_queue_name'
  }
}
ironmq.create_queue('queue_name', options)

Options:

Push queues only:

--

Same as create queue

Add or update subscribers on a push queue
subscribers = [
    {
        'name': 'first',
        'url': 'http://first.endpoint.xx/process',
        'headers': {
            'Content-Type': 'application/json'
        }
    },
    {
        'name': 'second',
        'url': 'http://second.endpoint.xx/process',
        'headers': {
            'Content-Type': 'application/json'
        }
    }
]
queue.add_subscribers(*subscribers)
Replace subscribers on a push queue

Sets list of subscribers to a queue. Older subscribers will be removed.

subscribers = [
    {
        "name": "the_only",
        "url": "http://my.over9k.host.com/push"
    }
];
queue.replace_subscribers(*subscribers);
Remove subscribers by a name from a push queue
queue.remove_subscribers('first', 'second')
Get the push statuses of a message
queue.get_message_push_statuses(message_id)

If you respond with a 202 status code, the pushed message will be reserved, not deleted, and should be manually deleted. You can get the message ID, reservation ID, and subscriber name from push request headers.

queue.delete(message_id, reservation_id, subscriber_name)

To delete a queue, use delete_queue:

You can find more documentation here:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4