/** * 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); }
/** * @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); }
/** * @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'); } }
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); }
/** * 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); }
/** * @param $job string * @return int */ public function sendJob($job) { return $this->beanStalkdClient->putInTube($this->sourceQueue, $job); }
/** * 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); }