private function processStateQueue($lastPublicationId = null)
{
if ($lastPublicationId !== null) {
// create an array of pub ids
// if we can't find the lastPublicationId in the queue
// then we are going to assume it was before our time
$pubIds = [];
/** @var EventMessage $msg */
foreach ($this->pauseQueue as $msg) {
$pubIds[] = $msg->getPublicationId();
}
if (!in_array($lastPublicationId, $pubIds)) {
$lastPublicationId = null;
}
}
while (!$this->pauseQueue->isEmpty()) {
$msg = $this->pauseQueue->dequeue();
if ($lastPublicationId === null) {
$this->sendEventMessage($msg);
}
if ($lastPublicationId == $msg->getPublicationId()) {
$lastPublicationId = null;
}
}
}