publish.

@param string  $messageType
@param Message $message
194290
public function publish($messageType, Message $message, array $overridenConfig = array())
    {
        if (!$this->isKnownMessageType($messageType)) {
            throw new \InvalidArgumentException(sprintf(
                'Unknown message type "%s". Available are [%s].',
                $messageType,
                implode(',', array_keys($this->messageTypes))
            ));
        }

        $config = $this->messageTypes[$messageType];

        $exchange = isset($overridenConfig['exchange']) ? $overridenConfig['exchange'] : $config['exchange'];
        $connection = isset($overridenConfig['connection']) ? $overridenConfig['connection'] : $config['connection'];
        $routingKey = isset($overridenConfig['routing_key']) ? $overridenConfig['routing_key'] : $config['routing_key'];

        $messagePublisher = $this->factory->getMessagePublisher($exchange, $connection);

        $this->logger->debug('Publish message in {exchange}:{routing_key} (connection {connection})', [
            'exchange' => $exchange,
            'routing_key' => $routingKey,
            'connection' => $connection,
        ]);

        $messagePublisher->publish($message, $routingKey);

        $this->eventDispatcher->dispatch(
            MessagePublishedEvent::NAME,
            new MessagePublishedEvent($messageType, $message, $connection, $exchange, $routingKey)
        );
    }
1328175
public function addMessage(Message $message)
    {
        $message->setMessageBroker($this);
        $this->messages->attach($message);
    }
728057
private function type($message, $type)
    {
        $this->type = $type;

        $this->message = $message;

        return $this;
    }
423408
public function PublishMessage($message, $tag = null, $attributes = null)
    {
        return $this->createMessage($message, $tag, $attributes)->send();
    }
345677
public function sendImage (Type\Image $message)
    {
        $this->sendReply(
            $this->buildMessage(
                [
                    'MsgType' => $message->getType(),
                    ucfirst($message->getType()) => [
                        'MediaId' => $message->getMediaID(),
                    ],
                ]
            )
        );
    }
202746
def publish(self, topic, message):
        """"""
        self.connect()
        log.info('publish {}'.format(message))
        self.client.publish(topic, message)
1179368
public function sendText (Type\Text $message)
    {
        $this->sendReply(
            $this->buildMessage(
                [
                    'MsgType' => $message->getType(),
                    'Content' => $message->getContent(),
                ]
            )
        );
    }
644912
public static function createForMessage($recipientOrPhone, Message $message, $notificationType = NotificationType::REGULAR, $messagingType = MessagingType::RESPONSE)
    {
        $options = [];
        $data = [
            'messaging_type' => $messagingType,
            'recipient' => self::createRecipientField($recipientOrPhone),
            'message' => $message,
            'notification_type' => $notificationType,
        ];
        
        if ($message->hasFileToUpload()) {

            // Create a multipart request
            $options[RequestOptions::MULTIPART] = [
                [
                  'name' => 'messaging_type',
                  'contents' => $messagingType
                ],
                [
                    'name' => 'recipient',
                    'contents' => json_encode($data['recipient']),
                ],
                [
                    'name' => 'message',
                    'contents' => json_encode($data['message']),
                ],
                [
                    'name' => 'notification_type',
                    'contents' => $data['notification_type'],
                ],
                [
                    'name' => 'filedata',
                    'contents' => $message->getFileStream(),
                ],
            ];

            // Update timeout if we upload a file
            $options['timeout'] = Client::DEFAULT_FILE_UPLOAD_TIMEOUT;

            return $options;
        }

        $options[RequestOptions::JSON] = $data;

        return $options;
    }
895222
public function publish($topic, $message, $qos = 0, $retain = 0, &$msgid = null)
    {
        # set dup 0
        $dup = 0;

        # initial msgid = 0
        $msgid = 0;

        return $this->do_publish($topic, $message, $qos, $retain, $msgid, $dup);
    }
1069376
public function logMessage(Message $message) {
        foreach($this->logger as $logger) {
            $logger->logMessage($message);
        }
    }
520078
private function createMessageObject(string $type, string $message): Notification
    {
        $msg = new Notification();

        $msg->setType($type);
        $msg->setMessage($message);

        $this->handler->add($msg);

        return $msg;
    }
774690
public function editMessageAction(Message $message)
    {
        $subject = $message->getSubject();
        $forum = $subject->getCategory()->getForum();
        $isModerator = $this->authorization->isGranted('moderate', new ResourceCollection(array($forum->getResourceNode())));

        if (!$isModerator && $this->tokenStorage->getToken()->getUser() !== $message->getCreator()) {
            throw new AccessDeniedException();
        }

        $oldContent = $message->getContent();
        $form = $this->container->get('form.factory')->create(new MessageType, new Message());
        $form->handleRequest($this->get('request'));

        if ($form->isValid()) {
            $newContent = $form->get('content')->getData();
            $this->manager->editMessage($message, $oldContent, $newContent);

            return new RedirectResponse(
                $this->generateUrl('claro_forum_messages', array('subject' => $subject->getId()))
            );
        }

        return array(
            'subject' => $subject,
            'form' => $form->createView(),
            'message' => $message,
            '_resource' => $forum,
            'workspace' => $forum->getResourceNode()->getWorkspace()
        );
    }
684722
protected function output($message, $type = self::OUTPUT_INFO)
    {
        $output = $this->getOutput();

        if ($output === null) {
            return;
        }

        // Chose color type of message
        switch ($type) {
            case self::OUTPUT_COMMENT:
                $logMethod = 'info';
                $prefix = '<comment>';
                $postfix = '</comment>';
                break;

            case self::OUTPUT_ERROR:
                $logMethod = 'critical';
                $prefix = '<error>';
                $postfix = '</error>';
                break;

            case self::OUTPUT_INFO:
            default:
                $logMethod = 'info';
                $prefix = '<info>';
                $postfix = '</info>';
                break;
        }

        $psrLogBase = self::PSR_LOG_BASE;
        $consoleBase = self::SYMFONY_CONSOLE_BASE;

        if ($output instanceof $psrLogBase) {
            $output->$logMethod($message);

        } else {
            if ($output instanceof $consoleBase) {
                $output->writeln($prefix . $message . $postfix);
            }
        }

    }
853570
public function publish($message)
    {
        /* @var Connection $conn */
        list($conn) = (yield $this->take());

        $conn->writeCmd(Command::publish($this->topic, $message));
        $this->stats["messagesPublished"]++;

        $timeout = NsqConfig::getPublishTimeout();
        $onTimeout = $this->onPublishTimeout($conn);
        $timerId = $this->getPublishTimeoutTimerId($conn);

        Timer::after($timeout, $onTimeout, $timerId);

        yield setContext("conn", $conn);
        yield $this;
    }
125597
public function sendMessage(Message $message)
    {
        $this->currentId++;
        $messageData = $message->convertToRconData($this->currentId);
        $this->client->write($messageData);

        return $this->getResponseMessage();
    }
510875
private function create($messageClass, $message)
    {
        $interfaces = array_values(class_implements($messageClass, true));
        return new IncomingLogicalMessage($message, $messageClass, $interfaces);
    }
615455
public function errorLog($type = 'debug', $messageType = ErrorLogHandler::OPERATING_SYSTEM)
    {
        $this->pushHandler(new ErrorLogHandler($messageType, $this->getLevel($type)));
    }