getTaskLog(); $broker = $this->getQueueDispatcher() ->getQueue($query->getQueryName()) ->getBroker(); if (!$broker instanceof RdsQueueBroker) { throw new InvalidArgumentException( sprintf( 'Broker %s for queue %s is not supported. Supported only %s', $broker->getBrokerId(), $query->getQueryName(), RdsQueueBroker::class ) ); } $filter = (new TaskLogFilter()) ->addFilter(TaskLogBrokerInterface::COLUMN_TASK_NAME, 'IN', $query->getWhitelist()) ->addFilter(TaskLogBrokerInterface::COLUMN_STATUS, 'IN', $query->getStatuses()) ->addFilter( TaskLogBrokerInterface::COLUMN_UPDATED_AT, '<=', $query->getAgeDateTime()->format('Y-m-d H:i:s') ); $taskLogs = $taskLog->search($filter); $tasks = new StuckTaskCollection(...[]); foreach ($taskLogs as $taskLogEntity) { if (!$this->isAgeConsistent($taskLogEntity, $query)) { continue; } $task = $broker->getTaskByTaskLogId($taskLogEntity->getId()); $tasks->add( new StuckTask( $taskLogEntity, $query->getQueryName(), $task ? $task->getTask() : null, $task ? $task->getTaskId() : null ) ); } return $tasks; } private function isAgeConsistent(EntityInterface $taskLogEntity, StuckTaskQuery $query): bool { return ($query->getAgeDateTime()->getTimestamp() - $taskLogEntity->getCreatedAt()->getTimestamp()) >= 0; } private function getTaskLog(): TaskLogInterface { return $this->getServiceLocator()->get(TaskLogInterface::SERVICE_ID); } private function getQueueDispatcher(): QueueDispatcherInterface { return $this->getServiceLocator()->get(QueueDispatcherInterface::SERVICE_ID); } }