Skip to content

Commit 9bd02df

Browse files
committed
Fix local vyuldashev#501 - laravel 9.41
1 parent e15f988 commit 9bd02df

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/Horizon/RabbitMQQueue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function later($delay, $job, $data = '', $queue = null)
6464
{
6565
$payload = (new JobPayload($this->createPayload($job, $data)))->prepare($job)->value;
6666

67-
return tap(parent::pushRaw($payload, $queue, ['delay' => $this->secondsUntil($delay)]), function () use ($payload, $queue): void {
67+
return tap(parent::laterRaw($delay, $payload, $queue), function () use ($payload, $queue): void {
6868
$this->event($this->getQueue($queue), new JobPushed($payload));
6969
});
7070
}

src/Queue/RabbitMQQueue.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,18 @@ public function laterRaw($delay, $payload, $queue = null, $attempts = 0)
188188
{
189189
$ttl = $this->secondsUntil($delay) * 1000;
190190

191+
// default options
192+
$options = ['delay' => $delay, 'attempts' => $attempts];
193+
191194
// When no ttl just publish a new message to the exchange or queue
192195
if ($ttl <= 0) {
193-
return $this->pushRaw($payload, $queue, ['delay' => $delay, 'attempts' => $attempts]);
196+
return $this->pushRaw($payload, $queue, $options);
194197
}
195198

199+
// Create a main queue to handle delayed messages
200+
[$mainDestination, $exchange, $exchangeType, $attempts] = $this->publishProperties($queue, $options);
201+
$this->declareDestination($mainDestination, $exchange, $exchangeType);
202+
196203
$destination = $this->getQueue($queue).'.delay.'.$ttl;
197204

198205
$this->declareQueue($destination, true, false, $this->getDelayQueueArguments($this->getQueue($queue), $ttl));
@@ -754,9 +761,9 @@ protected function getRoutingKey(string $destination): string
754761
protected function getExchangeType(?string $type = null): string
755762
{
756763
return @constant(AMQPExchangeType::class.'::'.Str::upper($type ?: Arr::get(
757-
$this->options,
758-
'exchange_type'
759-
) ?: 'direct')) ?: AMQPExchangeType::DIRECT;
764+
$this->options,
765+
'exchange_type'
766+
) ?: 'direct')) ?: AMQPExchangeType::DIRECT;
760767
}
761768

762769
/**

0 commit comments

Comments
 (0)