-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update due to yiisoft/queue changes #111
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,6 +8,7 @@ | |||||
use PhpAmqpLib\Message\AMQPMessage; | ||||||
use Throwable; | ||||||
use Yiisoft\Queue\Message\MessageInterface; | ||||||
use Yiisoft\Queue\Message\MessageSerializerInterface as MessageSerializerInterfaceAlias; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
/** | ||||||
* @internal | ||||||
|
@@ -17,9 +18,9 @@ | |||||
private bool $messageConsumed = false; | ||||||
|
||||||
public function __construct( | ||||||
private AMQPChannel $channel, | ||||||
private string $queueName, | ||||||
private MessageSerializerInterface $serializer | ||||||
private readonly AMQPChannel $channel, | ||||||
private readonly string $queueName, | ||||||
private readonly MessageSerializerInterfaceAlias $serializer | ||||||
) { | ||||||
} | ||||||
|
||||||
|
@@ -31,15 +32,15 @@ | |||||
$this->channel->basic_consume( | ||||||
$this->queueName, | ||||||
'', | ||||||
false, | ||||||
Check warning on line 35 in src/ExistingMessagesConsumer.php GitHub Actions / PHP 8.3-ubuntu-latest
|
||||||
false, | ||||||
false, | ||||||
Check warning on line 37 in src/ExistingMessagesConsumer.php GitHub Actions / PHP 8.3-ubuntu-latest
|
||||||
false, | ||||||
function (AMQPMessage $amqpMessage) use ($callback): void { | ||||||
try { | ||||||
$message = $this->serializer->unserialize($amqpMessage->body); | ||||||
$message = $this->serializer->unserialize($amqpMessage->getBody()); | ||||||
if ($this->messageConsumed = $callback($message)) { | ||||||
$this->channel->basic_ack($amqpMessage->getDeliveryTag()); | ||||||
Check warning on line 43 in src/ExistingMessagesConsumer.php GitHub Actions / PHP 8.3-ubuntu-latest
|
||||||
} | ||||||
} catch (Throwable $exception) { | ||||||
$this->messageConsumed = false; | ||||||
|
@@ -53,7 +54,7 @@ | |||||
} | ||||||
); | ||||||
|
||||||
do { | ||||||
Check warning on line 57 in src/ExistingMessagesConsumer.php GitHub Actions / PHP 8.3-ubuntu-latest
|
||||||
$this->messageConsumed = false; | ||||||
$this->channel->wait(null, true); | ||||||
} while ($this->messageConsumed === true); | ||||||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,5 +48,10 @@ protected function queueListen(?string $queue = null): void | |
$process = new Process($command); | ||
$this->processes[] = $process; | ||
$process->start(); | ||
|
||
usleep(500000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not really good to sleep during the tests |
||
if (!$process->isRunning()) { | ||
throw new \Exception('Failed to start queue listener process'); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better add enumeration support to
QueueProviderInterface