Skip to content

Commit 3ae7104

Browse files
committed
[Queue] Message try add createdAt field #1271
1 parent f859e51 commit 3ae7104

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

packages/queue/src/Driver/DatabaseQueueDriver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct(
5353
*/
5454
public function push(QueueMessage $message): string
5555
{
56-
$time = new DateTimeImmutable('now');
56+
$time = $message->createdAt ?? new DateTimeImmutable('now');
5757

5858
$data = [
5959
'channel' => $message->getChannel() ?: $this->channel,
@@ -143,7 +143,7 @@ function () use ($now, $query) {
143143
$message->setBody(json_decode($data['body'], true, 512, JSON_THROW_ON_ERROR));
144144
$message->setRawBody($data['body']);
145145
$message->setChannel($channel);
146-
$message->setCreatedAt($data['createdAt']);
146+
$message->setCreatedAt($data['created']);
147147

148148
return $message;
149149
}

packages/queue/src/Driver/InfinityQueueDriver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public function push(QueueMessage $message): string
2626
public function pop(?string $channel = null): ?QueueMessage
2727
{
2828
return new QueueMessage($this->job)
29-
->setId(uid('mq__'));
29+
->setId(uid('mq__'))
30+
->setCreatedAt('now');
3031
}
3132

3233
public function delete(QueueMessage $message): static

packages/queue/src/Driver/PdoQueueDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(
4949
*/
5050
public function push(QueueMessage $message): string
5151
{
52-
$time = new DateTimeImmutable('now');
52+
$time = $message->createdAt ?? new DateTimeImmutable('now');
5353

5454
$data = [
5555
':channel' => $message->getChannel() ?: $this->channel,

0 commit comments

Comments
 (0)