Blog

Search This Blog

Loading...

Monday, January 7, 2013

Peek, Touch and Release

IronMQ now supports three new operations: peek, touch and release. These operations give you greater control over handling your messages and here's a brief explanation of each.

A little background on the message lifecycle


First off, let's discuss the typical message lifecycle.
  1. POST message to a queue. 
  2. GET message from the queue - this reserves it.  
  3. DELETE message from the queue once you're done with it.
During the 2nd phase of the lifecycle, the GET phase, a message is reserved for a period of time defined by the "timeout" parameter (default is 60 seconds). If the message is not DELETEd before the end of the timeout, it will be placed back on the queue and become available again for the next GET.

Peek

Peek allows you to get messages off the queue without reserving them. Peek will not reserve the message and it will therefore remain available for the next peek or get operation. You can use this if you need to see if any messages are available.

Docs for peek.

Touch

Touching a reserved message extends its timeout by the duration specified when the message was created / POSTed. This is useful if your processing time is taking longer than expected and you want some more time to finish.

Docs for touch.

Release

Releasing a reserved message un-reserves the message and puts it back on the queue as if the message had timed out. This is useful if for some reason you can't process the message right away, you can put it back on the queue for another process to pick up. You can also supply a "delay" parameter.

Docs for release.