![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/vendor/php-amqplib/rabbitmq-bundle/RabbitMq/ |
<?php namespace OldSound\RabbitMqBundle\RabbitMq; use PhpAmqpLib\Message\AMQPMessage; class RpcServer extends BaseConsumer { private $serializer = 'serialize'; public function initServer($name) { $this->setExchangeOptions(['name' => $name, 'type' => 'direct']); $this->setQueueOptions(['name' => $name . '-queue']); } public function processMessage(AMQPMessage $msg) { try { $msg->ack(); $result = call_user_func($this->callback, $msg); $result = call_user_func($this->serializer, $result); $this->sendReply($result, $msg->get('reply_to'), $msg->get('correlation_id')); $this->consumed++; $this->maybeStopConsumer(); } catch (\Exception $e) { $this->sendReply('error: ' . $e->getMessage(), $msg->get('reply_to'), $msg->get('correlation_id')); } } protected function sendReply($result, $client, $correlationId) { $reply = new AMQPMessage($result, ['content_type' => 'text/plain', 'correlation_id' => $correlationId]); $this->getChannel()->basic_publish($reply, '', $client); } public function setSerializer($serializer) { $this->serializer = $serializer; } }