Skip to content

Commit 1b0c325

Browse files
committed
[dbal] fix remove expired messages.
1 parent 76f6583 commit 1b0c325

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎pkg/dbal/DbalConsumerHelperTrait.php‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ protected function redeliverMessages(): void
8484
{
8585
if (null === $this->redeliverMessagesLastExecutedAt) {
8686
$this->redeliverMessagesLastExecutedAt = microtime(true);
87-
}
88-
89-
if ((microtime(true) - $this->redeliverMessagesLastExecutedAt) < 1) {
87+
} elseif ((microtime(true) - $this->redeliverMessagesLastExecutedAt) < 1) {
9088
return;
9189
}
9290

@@ -109,15 +107,14 @@ protected function removeExpiredMessages(): void
109107
{
110108
if (null === $this->removeExpiredMessagesLastExecutedAt) {
111109
$this->removeExpiredMessagesLastExecutedAt = microtime(true);
112-
}
113-
114-
if ((microtime(true) - $this->removeExpiredMessagesLastExecutedAt) < 1) {
110+
} elseif ((microtime(true) - $this->removeExpiredMessagesLastExecutedAt) < 1) {
115111
return;
116112
}
117113

118114
$this->getConnection()->createQueryBuilder()
119115
->delete($this->getContext()->getTableName())
120116
->andWhere('(time_to_live IS NOT NULL) AND (time_to_live < :now)')
117+
->andWhere('(redelivered = false OR delivery_id IS NULL)')
121118
->setParameter(':now', (int) time(), Type::BIGINT)
122119
->setParameter('redelivered', false, Type::BOOLEAN)
123120
->execute()

0 commit comments

Comments
 (0)