Exemple #1
0
 public function testDeliveryInfo()
 {
     $expected = 'propRoutingKey';
     $message = new Message();
     $message->setPropRoutingKey($expected);
     $this->assertEquals($expected, $message->getPropRoutingKey());
 }
Exemple #2
0
 /**
  * <b> Options:</b>
  * - 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: Simple routing (name <-> name) is accomplished using the queue option.
  * - queue_args
  * - exchange: Name of exchange (or a kombu.entity.Exchange) to send the message to.
  * 
  * @param array $options
  * @throws \RuntimeException
  * @return Task
  */
 public function delay($options = array())
 {
     if ($this->getTaskSent()) {
         throw new \RuntimeException('Task has been sent');
     }
     if (isset($options['countdown'])) {
         $this->setCountdown($options['countdown']);
     }
     if (isset($options['expires'])) {
         $this->setExpires($options['expires']);
     }
     if (isset($options['priority'])) {
         $this->setPriority($options['priority']);
         $this->getMessage()->setPropPriority($options['priority']);
     }
     if (isset($options['no_ack'])) {
         $this->getMessage()->setPropNoAck($options['no_ack']);
     }
     if (isset($options['delivery_tag'])) {
         $this->getMessage()->setPropDeliveryTag($options['delivery_tag']);
     }
     if (isset($options['delivery_mode'])) {
         $this->getMessage()->setPropDeliveryMode($options['delivery_mode']);
     }
     if (isset($options['utc'])) {
         $this->setUtc((bool) $options['utc']);
     }
     if (isset($options['eta'])) {
         $this->setEta($options['eta']);
     }
     if (isset($options['errbacks'])) {
         $this->setCallbacks($options['errbacks']);
     }
     if (isset($options['queue'])) {
         $this->message->setQueue($options['queue']);
     }
     if (isset($options['queue_args'])) {
         $this->message->setPropQueueArgs($options['queue_args']);
     }
     if (isset($options['routing_key'])) {
         $this->message->setPropRoutingKey($options['routing_key']);
     }
     if (isset($options['exchange'])) {
         $this->message->setPropExchange($options['exchange']);
     } else {
         $this->message->setPropExchange(Rhubarb::RHUBARB_DEFAULT_EXCHANGE_NAME);
     }
     $this->setTaskSent(true);
     $this->getRhubarb()->getBroker()->publishTask($this);
     return $this;
 }