コード例 #1
0
 /**
  * Publish a message to the queue
  *
  * @param Message $message
  * @return void
  */
 public function publish(Message $message)
 {
     $encodedMessage = $this->encodeMessage($message);
     $messageIdentifier = $this->client->putInTube($this->name, $encodedMessage);
     $message->setIdentifier($messageIdentifier);
     $message->setState(Message::STATE_PUBLISHED);
 }
コード例 #2
0
 /**
  * @inheritdoc
  */
 public function submit($payload, array $options = [])
 {
     $priority = isset($options['priority']) ? (int) $options['priority'] : PheanstalkInterface::DEFAULT_PRIORITY;
     $delay = isset($options['delay']) ? (int) $options['delay'] : PheanstalkInterface::DEFAULT_DELAY;
     $ttr = isset($options['ttr']) ? (int) $options['ttr'] : PheanstalkInterface::DEFAULT_TTR;
     return (string) $this->client->putInTube($this->name, json_encode($payload), $priority, $delay, $ttr);
 }
コード例 #3
0
 /**
  * @param Pheanstalk $transport
  * @param null $tube
  * @param MailWrappedMessage|null $message
  * @return int
  * @throws MailWrapperSendException
  * @throws MailWrapperSetupException
  */
 public static function store(Pheanstalk $transport, $tube = null, MailWrappedMessage $message = null)
 {
     if (!$message || !$message instanceof MailWrappedMessage) {
         throw new MailWrapperSetupException('No Message');
     }
     if (!is_string($tube)) {
         throw new MailWrapperSetupException('No Tube');
     }
     try {
         $storageId = $transport->putInTube($tube, $message);
         return $storageId;
     } catch (\Exception $exception) {
         throw new MailWrapperSendException('Message store failure');
     }
 }
コード例 #4
0
ファイル: BeanstalkdQueue.php プロジェクト: vksee/yii2-queue
 public function push($payload, $queue, $delay = PheanstalkInterface::DEFAULT_DELAY)
 {
     return $this->beanstalkd->putInTube($queue, is_string($payload) ? $payload : Json::encode($payload), PheanstalkInterface::DEFAULT_PRIORITY, $delay, PheanstalkInterface::DEFAULT_TTR);
 }
コード例 #5
0
 /**
  * Valid options are:
  *      - priority: the lower the priority is, the sooner the job get popped from the queue (default to 1024)
  *      - delay: the delay in seconds before a job become available to be popped (default to 0 - no delay -)
  *      - ttr: in seconds, how much time a job can be reserved for (default to 60)
  *
  * {@inheritDoc}
  */
 public function push(JobInterface $job, array $options = array())
 {
     $identifier = $this->pheanstalk->putInTube($this->getTubeName(), $this->serializeJob($job), isset($options['priority']) ? $options['priority'] : Pheanstalk::DEFAULT_PRIORITY, isset($options['delay']) ? $options['delay'] : Pheanstalk::DEFAULT_DELAY, isset($options['ttr']) ? $options['ttr'] : Pheanstalk::DEFAULT_TTR);
     $job->setId($identifier);
 }
コード例 #6
0
ファイル: BeanStalkdQueue.php プロジェクト: yemexx1/simpleue
 /**
  * @param $job string
  * @return int
  */
 public function sendJob($job)
 {
     return $this->beanStalkdClient->putInTube($this->sourceQueue, $job);
 }
コード例 #7
0
 /**
  * Post/Put a message on to the queue server
  *
  * @param string $message Message Body to be send
  * @param string $queue Queue Name
  */
 public function addMessageToQueue($message, $queue)
 {
     $this->queue->putInTube($queue, $message);
 }