



Search — Rhubarb documentation

### Navigation

* [index](genindex.html "General Index")

* [Rhubarb documentation](index.html) »

Search

======

 Please activate JavaScript to enable the search

 functionality.

 

 From here you can search these documents. Enter your search

 words into the box below and click "search". Note that the search

 function will automatically search for all of the words. Pages

 containing fewer words won't appear in the result list.

 

### Navigation

* [index](genindex.html "General Index")

* [Rhubarb documentation](index.html) »

 © Copyright 2012, Robert Allen.

 Created using [Sphinx](http://sphinx.pocoo.org/) 1.1.3.

 





Installation — Rhubarb documentation

### Navigation

* [index](genindex.html "General Index")

* [next](rhubarb.html "Rhubarb") |

* [previous](index.html "Welcome to Rhubarb’s documentation!") |

* [Rhubarb documentation](index.html) »

Installation[¶](#installation "Permalink to this headline")

===========================================================

Composer[¶](#composer "Permalink to this headline")

---------------------------------------------------

> 

> The recommended method of installation is via [composer](http://getcomposer.org)

> 

> 

> 

> ```

> composer require zircote/rhubarb:3.1.*

> 

> ```

> 

> 

> Depending on your selection of connectors you will also need to require or compile

> the appropriate extension or libraries.

> 

> 

> Extensions may be installed with pecl i.e.

> 

> 

> 

> ```

> pecl install mongo

> 

> ```

> 

> 

> Libraries can be included utilizing the composer command

> 

> 

> 

> ```

> composer require predis/predis:master-dev

> 

> ```

> 

> 

> 

PECL AMQP[¶](#pecl-amqp "Permalink to this headline")

-----------------------------------------------------

Development of the Official PHP AMQP extension may be found at <https://github.com/bkw/pecl-amqp-official> as well as stubs and tests.

Installation via pecl:

To build the ext-amqp from source:

> 

> 

### [Table Of Contents](index.html)

* [Installation](#)

	+ [Composer](#composer)

	+ [PECL AMQP](#pecl-amqp)

#### Previous topic

[Welcome to Rhubarb’s documentation!](index.html "previous chapter")

#### Next topic

[Rhubarb](rhubarb.html "next chapter")

### Quick search

 Enter search terms or a module, class or function name.

 

### Navigation

* [index](genindex.html "General Index")

* [next](rhubarb.html "Rhubarb") |

* [previous](index.html "Welcome to Rhubarb’s documentation!") |

* [Rhubarb documentation](index.html) »

 © Copyright 2012, Robert Allen.

 Created using [Sphinx](http://sphinx.pocoo.org/) 1.1.3.

 





Index — Rhubarb documentation

### Navigation

* [index](# "General Index")

* [Rhubarb documentation](index.html) »

Index

=====

### Quick search

 Enter search terms or a module, class or function name.

 

### Navigation

* [index](# "General Index")

* [Rhubarb documentation](index.html) »

 © Copyright 2012, Robert Allen.

 Created using [Sphinx](http://sphinx.pocoo.org/) 1.1.3.

 





Rhubarb — Rhubarb documentation

### Navigation

* [index](genindex.html "General Index")

* [next](connectors/index.html "Rhubarb Connectors") |

* [previous](installation.html "Installation") |

* [Rhubarb documentation](index.html) »

Rhubarb[¶](#rhubarb "Permalink to this headline")

=================================================

Celery Worker Execution From PHP

Use of Rhubarb is outlined as follows.

**Send Task and Wait For Result**

```

use \Rhubarb\Exception\TimeoutException;

$rhubarb = new \Rhubarb\Rhubarb($options);

try {

   $task = $rhubarb->sendTask('task.add', array(2,2));

   $task->delay();

   $result = $task->get();

} catch (TimeoutException $e) {

   $log->error('task failed to return in default timelimit [10] seconds');

}

```

**Fire And Forget Task**

```

use \Rhubarb\Exception\TimeoutException;

$rhubarb = new \Rhubarb\Rhubarb($options);

try {

   $task = $rhubarb->sendTask('task.add', array(2,2));

   $result = $task->delay();

} catch (TimeoutException $e) {

   $log->error('task failed to return in default timelimit [10] seconds');

}

```

**Getting Task Status**

```

use \Rhubarb\Exception\TimeoutException;

$rhubarb = new \Rhubarb\Rhubarb($options);

$task = $rhubarb->sendTask('task.add', array(2,2));

$result = $task->delay();

while (!$task->successful()) {

   echo $task->state(), PHP\_EOL;

   // You should have some time based break; statement here

}

var\_dump($task->get());

```

**KWARG Support**

```

use \Rhubarb\Exception\TimeoutException;

$rhubarb = new \Rhubarb\Rhubarb($options);

try {

   $task = $rhubarb->sendTask('task.add', array('arg1' => 2, 'arg2' => 2));

   $result = $task->delay();

   var\_dump($task->get());

} catch (TimeoutException $e) {

   $log->error('task failed to return in default timelimit [10] seconds');

}

```

**Method Specific Queue and/or Exchange**

```

use \Rhubarb\Exception\TimeoutException;

$rhubarb = new \Rhubarb\Rhubarb($options);

try {

   $task = $rhubarb->sendTask('task.add', array('arg1' => 2, 'arg2' => 2));

   $task->getMessage()

       ->setPropQueue('priority.high')

       ->setPropExchange('queue.other');

   $result = $task->delay();

   var\_dump($task->get());

} catch (TimeoutException $e) {

   $log->error('task failed to return in default timelimit [10] seconds');

}

```

**Advanced Task Options**

At runtime it may become necessary to utilize a different queue, exchange or various runtime options. These options may

be passed to the \_\_delay\_\_ method when called:

Supported Options are:

* countdown: (int) The task is guaranteed to be executed at some time after the specified date and time, but not necessarily at that exact time.

* expires: (int) The expires argument defines an optional expiry time, either as seconds after task publish.

* priority: (int) A number between 0 and 9, where 0 is the highest priority. (Supported by: redis)

* utc: (bool) Timestamps are UTC.

* eta: (int) The ETA (estimated time of arrival) in seconds; lets you set a specific date and time that is the earliest time at which your task will be executed.

* errbacks: TBD

* queue: (string) Simple routing (name <-> name) is accomplished using the queue option.

* queue\_args: (array) Key-Value option pairs for the queue arguments.

* exchange: (string) Name of exchange (or a kombu.entity.Exchange) to send the message to.

**Example**

```

$rhubarb = new \Rhubarb\Rhubarb($options);

$res = $rhubarb->sendTask('subtract', array(3, 2));

$res->delay(

    array(

        'queue' => 'priority.high',

        'exchange' => 'subtract\_queue'

    )

);

$result = $res->get(2);

$this->assertEquals(1, $result);

```

#### Previous topic

[Installation](installation.html "previous chapter")

#### Next topic

[Rhubarb Connectors](connectors/index.html "next chapter")

### Quick search

 Enter search terms or a module, class or function name.

 

### Navigation

* [index](genindex.html "General Index")

* [next](connectors/index.html "Rhubarb Connectors") |

* [previous](installation.html "Installation") |

* [Rhubarb documentation](index.html) »

 © Copyright 2012, Robert Allen.

 Created using [Sphinx](http://sphinx.pocoo.org/) 1.1.3.

 





Welcome to Rhubarb’s documentation! — Rhubarb documentation

### Navigation

* [index](genindex.html "General Index")

* [next](installation.html "Installation") |

* [Rhubarb documentation](#) »

Welcome to Rhubarb’s documentation![¶](#welcome-to-rhubarb-s-documentation "Permalink to this headline")

========================================================================================================

Contents:

* [Installation](installation.html)

	+ [Composer](installation.html#composer)

	+ [PECL AMQP](installation.html#pecl-amqp)

* [Rhubarb](rhubarb.html)

* [Rhubarb Connectors](connectors/index.html)

	+ [AMQP](connectors/amqp.html)

		- [zircote/amqp](connectors/amqp.html#id1)

		- [ext-amqp](connectors/amqp.html#id2)

	+ [redis](connectors/redis.html)

		- [predis/predis](connectors/redis.html#id2)

	+ [Mongo](connectors/mongo.html)

Indices and tables[¶](#indices-and-tables "Permalink to this headline")

=======================================================================

* [*Index*](genindex.html)

* [*Module Index*](py-modindex.html)

* [*Search Page*](search.html)

### [Table Of Contents](#)

* [Welcome to Rhubarb’s documentation!](#)

* [Indices and tables](#indices-and-tables)

#### Next topic

[Installation](installation.html "next chapter")

### Quick search

 Enter search terms or a module, class or function name.

 

### Navigation

* [index](genindex.html "General Index")

* [next](installation.html "Installation") |

* [Rhubarb documentation](#) »

 © Copyright 2012, Robert Allen.

 Created using [Sphinx](http://sphinx.pocoo.org/) 1.1.3.

 





AMQP — Rhubarb documentation

### Navigation

* [index](../genindex.html "General Index")

* [next](redis.html "redis") |

* [previous](index.html "Rhubarb Connectors") |

* [Rhubarb documentation](../index.html) »

* [Rhubarb Connectors](index.html) »

AMQP[¶](#amqp "Permalink to this headline")

===========================================

**Rhubarb** currently supports two **AMQP** connectors:

* [zircote/amqp](https://packagist.org/packages/zircote/amqp)

* [ext-amqp](https://github.com/bkw/php-amqp)

Note

Note that at this time the **ext-amqp** extension does not support *TLS*; for *TLS* support you will be required to utilize the **zircote/amqp** package.

zircote/amqp[¶](#id1 "Permalink to this headline")

--------------------------------------------------

Configuration

The configuration of the *zircote/amqp* implementation for **Rhubarb** is comprised of the following key hierarchy:

> 

> * **broker**

> 

> 	+ **type**: the broker class name without the namespace

> 	+ **options**: the broker specific options

> 	

> 		- **exchange**: the name of the target exchange

> 		- **queue**: an array of options related to the queue

> 		

> 			* **name**: the queue name

> 			* **arguments**: an array of arguments related to the queue, these are AMQP specific and are documented in the *zircote/amqp* library

> 		- **uri**: the amqp server/cluster uri (it should match your celery worker configuration)

> * **result\_store**

> 

> 	+ **type**: the result\_store class name without the namespace

> 	+ **options**: the result\_store specific options

> 	

> 		- **exchange**: the name of the target exchange

> 	+ **uri**: the amqp server/cluster uri (it should match your celery worker configuration)

> 

> 

> 

Note

These options SHOULD match your celery worker configuration.

```

$options = array(

    'broker' => array(

        'type' => 'Amqp',

        'options' => array(

            'exchange' => 'celery',

            'queue' => array(

                'name' => 'celery',

                'arguments' => array(

                    'x-ha-policy' => array('S', 'all')

                )

            ),

            'connection' => 'amqp://guest:guest@localhost:5672/celery'

        )

    ),

    'result\_store' => array(

        'type' => 'Amqp',

        'options' => array(

            'exchange' => 'celery',

            'connection' => 'amqp://guest:guest@localhost:5672/celery'

        )

    )

);

$rhubarb = new \Rhubarb\Rhubarb($options);

```

ext-amqp[¶](#id2 "Permalink to this headline")

----------------------------------------------

Configuration

The configuration of the *ext-amqp* implementation for **Rhubarb** is comprised of the following key hierarchy:

> 

> * **broker**

> 

> 	+ **type**: the broker class name without the namespace

> 	+ **options**: the broker specific options

> 	

> 		- **exchange**: the name of the target exchange

> 		- **queue**: an array of options related to the queue

> 		

> 			* **name**: the queue name

> 			* **arguments**: an array of arguments related to the queue, these are AMQP specific

> 		- **uri**: the amqp server/cluster uri (it should match your celery worker configuration)

> * **result\_store**

> 

> 	+ **type**: the result\_store class name without the namespace

> 	+ **options**: the result\_store specific options

> 	

> 		- **exchange**: the name of the target exchange

> 	+ **uri**: the amqp server/cluster uri (it SHOULD match your celery worker configuration)

> 

> 

> 

Note

These options SHOULD match your celery worker configuration.

```

$options = array(

    'broker' => array(

        'type' => 'PhpAmqp',

        'options' => array(

            'exchange' => 'celery',

            'queue' => array(

                'arguments' => array(

                )

            ),

            'connection' => 'amqp://guest:guest@localhost:5672/celery'

        )

    ),

    'result\_store' => array(

        'type' => 'PhpAmqp',

        'options' => array(

            'exchange' => 'celery',

            'connection' => 'amqp://guest:guest@localhost:5672/celery'

        )

    )

);

$rhubarb = new \Rhubarb\Rhubarb($options);

```

### [Table Of Contents](../index.html)

* [AMQP](#)

	+ [zircote/amqp](#id1)

	+ [ext-amqp](#id2)

#### Previous topic

[Rhubarb Connectors](index.html "previous chapter")

#### Next topic

[redis](redis.html "next chapter")

### Quick search

 Enter search terms or a module, class or function name.

 

### Navigation

* [index](../genindex.html "General Index")

* [next](redis.html "redis") |

* [previous](index.html "Rhubarb Connectors") |

* [Rhubarb documentation](../index.html) »

* [Rhubarb Connectors](index.html) »

 © Copyright 2012, Robert Allen.

 Created using [Sphinx](http://sphinx.pocoo.org/) 1.1.3.

 





Mongo — Rhubarb documentation

### Navigation

* [index](../genindex.html "General Index")

* [previous](redis.html "redis") |

* [Rhubarb documentation](../index.html) »

* [Rhubarb Connectors](index.html) »

Mongo[¶](#mongo "Permalink to this headline")

=============================================

Warning

as of Celery v3.1 MongoDB is no longer officially supported. Refer to Rhubarb v.0.2

#### Previous topic

[redis](redis.html "previous chapter")

### Quick search

 Enter search terms or a module, class or function name.

 

### Navigation

* [index](../genindex.html "General Index")

* [previous](redis.html "redis") |

* [Rhubarb documentation](../index.html) »

* [Rhubarb Connectors](index.html) »

 © Copyright 2012, Robert Allen.

 Created using [Sphinx](http://sphinx.pocoo.org/) 1.1.3.

 





Rhubarb Connectors — Rhubarb documentation

### Navigation

* [index](../genindex.html "General Index")

* [next](amqp.html "AMQP") |

* [previous](../rhubarb.html "Rhubarb") |

* [Rhubarb documentation](../index.html) »

Rhubarb Connectors[¶](#rhubarb-connectors "Permalink to this headline")

=======================================================================

Contents:

* [AMQP](amqp.html)

	+ [zircote/amqp](amqp.html#id1)

	+ [ext-amqp](amqp.html#id2)

* [redis](redis.html)

	+ [predis/predis](redis.html#id2)

* [Mongo](mongo.html)

#### Previous topic

[Rhubarb](../rhubarb.html "previous chapter")

#### Next topic

[AMQP](amqp.html "next chapter")

### Quick search

 Enter search terms or a module, class or function name.

 

### Navigation

* [index](../genindex.html "General Index")

* [next](amqp.html "AMQP") |

* [previous](../rhubarb.html "Rhubarb") |

* [Rhubarb documentation](../index.html) »

 © Copyright 2012, Robert Allen.

 Created using [Sphinx](http://sphinx.pocoo.org/) 1.1.3.

 





redis — Rhubarb documentation

### Navigation

* [index](../genindex.html "General Index")

* [next](mongo.html "Mongo") |

* [previous](amqp.html "AMQP") |

* [Rhubarb documentation](../index.html) »

* [Rhubarb Connectors](index.html) »

redis[¶](#redis "Permalink to this headline")

=============================================

**Rhubarb** currently supports one [\*\*redis\*\*](http://redis.io) connectors:

* [predis/predis](https://packagist.org/packages/predis/predis)

predis/predis[¶](#id2 "Permalink to this headline")

---------------------------------------------------

Configuration

The configuration of the *predis/predis* implementation for **Rhubarb** is comprised of the following key hierarchy:

> 

> * **broker**

> 

> 	+ **type**: the broker class name without the namespace

> 	+ **options**: the broker specific options

> 	

> 		- **exchange**: the name of the target exchange

> 		- **uri**: the amqp server/cluster uri (it should match your celery worker configuration)

> * **result\_store**

> 

> 	+ **type**: the result\_store class name without the namespace

> 	+ **options**: the result\_store specific options

> 	

> 		- **exchange**: the name of the target exchange

> 		- **uri**: the amqp server/cluster uri (it should match your celery worker configuration)

> 

> 

> 

Note

These options SHOULD match your celery worker configuration.

```

  $options = array(

      'broker' => array(

          'type' => 'Predis',

          'options' => array(

              'exchange' => 'celery',

              'connection' => 'redis://localhost:6379/1'

          )

      ),

      'result\_store' => array(

          'type' => 'Predis',

          'options' => array(

              'exchange' => 'celery',

          )

      )

  );

$rhubarb = new \Rhubarb\Rhubarb($options);

```

### [Table Of Contents](../index.html)

* [redis](#)

	+ [predis/predis](#id2)

#### Previous topic

[AMQP](amqp.html "previous chapter")

#### Next topic

[Mongo](mongo.html "next chapter")

### Quick search

 Enter search terms or a module, class or function name.

 

### Navigation

* [index](../genindex.html "General Index")

* [next](mongo.html "Mongo") |

* [previous](amqp.html "AMQP") |

* [Rhubarb documentation](../index.html) »

* [Rhubarb Connectors](index.html) »

 © Copyright 2012, Robert Allen.

 Created using [Sphinx](http://sphinx.pocoo.org/) 1.1.3.

 

