public function publishNotifications($exchangeName)
{
$publishedMessageTracker = $this->publishedMessageTracker();
$notifications = $this->listUnpublishedNotifications($publishedMessageTracker->mostRecentPublishedMessageId($exchangeName));
if (!$notifications) {
return 0;
}
$messageProducer = $this->messageProducer();
$messageProducer->open($exchangeName);
try {
$publishedMessages = 0;
$lastPublishedNotification = null;
foreach ($notifications as $notification) {
$lastPublishedNotification = $this->publish($exchangeName, $notification, $messageProducer);
$publishedMessages++;
}
} catch (\Exception $e) {
}
$this->trackMostRecentPublishedMessage($publishedMessageTracker, $exchangeName, $lastPublishedNotification);
$messageProducer->close($exchangeName);
return $publishedMessages;
}