public function onFail(CommandHandlerFailedException $exception) { if ($this->logger) { $this->logger->error(sprintf('[NoneStrategy] command [%s] failed.', get_class($exception->getCommand()))); } // noop }
public function onFail(CommandHandlerFailedException $exception) { if ($this->logger) { $this->logger->error(sprintf('[RequeueStrategy] command [%s] failed. Requeue it.', get_class($exception->getCommand()))); } $this->commandBus->handle($exception->getCommand(), $this->priority); }
public function onFail(CommandHandlerFailedException $exception) { $command = $exception->getCommand(); if ($command instanceof RetryCommand) { if ($command->getTryCount() === $this->failOnCount) { $command = new FailedCommand($command->getCommand(), $this->failOnCount); } else { $command->incrementTryCount(); } } elseif ($command instanceof FailedCommand) { if ($this->logger) { $this->logger->error(sprintf('[RetryThenFailStrategy] command [%s] go to failed queue.', get_class($command->getCommand()))); } if ($this->requeueOnFail) { $command->incrementTryCount(); } else { return; } } else { $command = new RetryCommand($command); } if ($this->logger) { $this->logger->error(sprintf('[RetryThenFailStrategy] command [%s] failed, attemps %d.', get_class($command->getCommand()), $command->getTryCount())); } $this->commandBus->handle($command, $this->priority); }