0

Final Class Yiisoft\Queue\SyncQueueProducer

InheritanceYiisoft\Queue\SyncQueueProducer
ImplementsYiisoft\Queue\QueueProducerInterface

Producer that runs each message synchronously, in the same process as the caller.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Psr\Log\LoggerInterface $logger, Yiisoft\Queue\Middleware\Push\PushMiddlewareConfig $middlewareConfig, Yiisoft\Queue\Worker\WorkerInterface $worker, string|\BackedEnum $queueName DefaultQueue::NAME, array $middlewareDefinitions = [] )
$logger \Psr\Log\LoggerInterface
$middlewareConfig Yiisoft\Queue\Middleware\Push\PushMiddlewareConfig
$worker Yiisoft\Queue\Worker\WorkerInterface
$queueName string|\BackedEnum
$middlewareDefinitions array

Queue-specific push middleware definitions.

                public function __construct(
    private readonly LoggerInterface $logger,
    PushMiddlewareConfig $middlewareConfig,
    WorkerInterface $worker,
    string|BackedEnum $queueName = DefaultQueue::NAME,
    array $middlewareDefinitions = [],
) {
    $this->queueName = StringNormalizer::normalize($queueName);
    $this->dispatcher = new PushMiddlewareDispatcher(
        middlewareFactory: $middlewareConfig->middlewareFactory,
        middlewareDefinitions: [...$middlewareConfig->commonMiddlewareDefinitions, ...$middlewareDefinitions],
        finishHandler: new SynchronousPushHandler($worker, $this),
    );
}

            
getQueueName() public method

public string getQueueName ( )

                public function getQueueName(): string
{
    return $this->queueName;
}

            
push() public method

public Yiisoft\Queue\Message\MessageInterface push ( Yiisoft\Queue\Message\MessageInterface $message )
$message Yiisoft\Queue\Message\MessageInterface

                public function push(MessageInterface $message): MessageInterface
{
    $this->logger->debug('Preparing to push message with message type "{messageType}".', ['messageType' => $message->getType()]);
    $message = $this->dispatcher->dispatch($message);
    $this->logger->info('Processed message with message type "{messageType}" synchronously.', ['messageType' => $message->getType()]);
    return $message;
}

            
status() public method

public \Yiisoft\Queue\MessageStatus status ( string|integer $id )
$id string|integer

                public function status(string|int $id): MessageStatus
{
    return MessageStatus::NOT_FOUND;
}