public function work() { try { $message = ChangeVO::create(); $message->setDatetime(new DateTime())->setMessage("Hi there!"); $this->changeProducer->publish($message); } catch (\Exception $e) { $this->log->critical("Couldn't push to pipeline. Possible missing rabbit on your machine?"); throw $e; } }
public function handleMessage(ChangeVO $change, Message $message, Channel $channel) { if ($message->routingKey === RoutingKeys::CHANGE_MANUAL_DONE) { $this->log->info("BREAKING CYCLE: " . ChangeVOMeta::toJson($change) . "."); $channel->ack($message); return; } else { $this->log->debug("Got message '" . $change->getMessage() . "' created at " . $change->getDatetime()->format("Y-m-d H:i:s") . " via application " . $change->getApplication() . " on host " . $change->getHostname() . " Acking..."); $channel->ack($message); $this->changeDoneProducer->publish($change, RoutingKeys::CHANGE_MANUAL_DONE); } }