Example #1
0
 /**
  * {@inheritdoc}
  */
 public function handle(CommandInterface $command, $priority = null)
 {
     $this->eventDispatcher->dispatch(Event\Events::PRE_HANDLE_COMMAND, new Event\PreHandleCommandEvent($this, $command));
     $serializedCommand = $this->serializer->serialize($command);
     if ($this->logger) {
         $this->logger->info(sprintf('[RedisCommandBus] Add command [%s] with content [%s] to the queue', get_class($command), $serializedCommand));
     }
     $redisMethod = $priority >= CommandBusInterface::PRIORITY_HIGH ? 'lpush' : 'rpush';
     $this->client->{$redisMethod}($this->keyGenerator->generate(get_class($command)), $serializedCommand);
 }
 /**
  * {@inheritdoc}
  */
 public function dequeue($commandClass = null)
 {
     $commandSerialized = $this->client->blpop($this->keyGenerator->generate($commandClass), (int) $this->readBlockTimeout);
     return false === empty($commandSerialized) ? $this->serializer->deserialize($commandSerialized[1]) : null;
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function handle(CommandInterface $command, $priority = null)
 {
     $serializedCommand = $this->serializer->serialize($command);
     $redisMethod = $priority >= CommandBusInterface::PRIORITY_HIGH ? 'lpush' : 'rpush';
     $this->client->{$redisMethod}($this->keyGenerator->generate(get_class($command)), $serializedCommand);
 }