Publish a message to the bus.

@param  {String} topic
@param  {String} msg
336708
function publish(topic, msg) {
  if (!topic || !msg || typeof topic !== 'string' || typeof msg !== 'object') {
    throw new Error('A `topic` (string) and `msg` (object) property must be defined');
  }

  if (module.exports.client && BUS_MODULE) {
    module.exports.client.publish(`${NAMESPACE}:${topic}`, msg);
  } else if (module.exports.client) {
    module.exports.client.publish(`${NAMESPACE}:${topic}`, JSON.stringify(msg));
  }
}
1225594
public int sendMessageToTopic(Collection<Session> sessionTargets, MessageToClient mtc, Object payload) {
		int sended = 0;
		logger.debug("Sending message to topic {}...", mtc);
		Collection<Session> doublons = topicManager.getSessionsForTopic(mtc.getId());
		if (doublons != null && !doublons.isEmpty()) {
			Set<Session> sessions = new HashSet<>(doublons);
			if (sessionTargets != null) {
				sessions.retainAll(sessionTargets);
			}
			sended = sendMessageToTopicForSessions(sessions, mtc, payload);
		} else {
			logger.debug("No client for topic '{}'", mtc.getId());
		}
		return sended;
	}
691428
public PubsubFuture<List<String>> publish(final String project, final String topic,
                                            final Message... messages) {
    return publish(project, topic, asList(messages));
  }
1034437
@Override
	public void publish(Message message) throws JMSException
    {
        send(message,defaultDeliveryMode,defaultPriority,defaultTimeToLive);
    }
1119688
def send(self,message,message_type,topic=''):
        
        if message_type == RAW:
            self._sock.send(message)
        elif message_type == PYOBJ:
            self._sock.send_pyobj(message)
        elif message_type == JSON:
            self._sock.send_json(message)
        elif message_type == MULTIPART:
            self._sock.send_multipart([topic, message])
        elif message_type == STRING:
            self._sock.send_string(message)
        elif message_type == UNICODE:
            self._sock.send_unicode(message)
        else:
            raise Exception("Unknown message type %s"%(message_type,))
481619
function(msg) {
        if (onSendLogging)
          asyncLogger("Send", msg);

        switch (protocol) {
          case 'websocket':
            if (socketState === socketStateType.OPEN) {
              socket.emit(msg);
            } else {
              pushSendDataQueue.push(msg);
            }
            break;

          case 'queue':
            if (socketState === socketStateType.OPEN) {
              activemq.sendMessage({
                destination: params.queueSend,
                message: msg
              });
            } else {
              pushSendDataQueue.push(msg);
            }
            break;
        }
      }
1220978
def multipublish(self, topic, messages):
        
        self.send(nsq.multipublish(topic, messages))
13648
def notify_event(self, session_info, topic):
        
        try:
            self.event_bus.sendMessage(topic, items=session_info)
        except AttributeError:
            msg = "Could not publish {} event".format(topic)
            raise AttributeError(msg)
609093
function publish (channel, ...args) {
    _publishStream.emit('message', channel, uniqueId(`${node.name}_`), ...args)
  }
233760
def sendMessage(self, msg):
        
        if msg._messageType in (1, 2):
            assert msg.destination, 'Failed to specify a message destination'

        if msg.destination is not None:
            if msg.destination[0] == ':':
                p = self.clients.get(msg.destination, None)
            else:
                p = self.busNames.get(msg.destination, None)
                if p:
                    p = p[0]

            # print 'SND: ', msg._messageType, ' to ',  p.uniqueName, 'serial',
            # msg.serial,

            if p:
                p.sendMessage(msg)
            else:
                log.msg(
                    'Invalid bus name in msg.destination: '
                    + msg.destination
                )
        else:
            self.router.routeMessage(msg)
1232536
def send_news_to(address, topic, data=None):
    
    _logger.info("Publish topic %s with data %s to %s", topic, data, address)
    return sockets._sockets.send_news_to(address, topic, data)
875168
public function publish($topicName, $message, $tags = [])
    {
        $params = [
            'topicName' => $topicName,
            'msgBody'   => Utils::serializeMessage($message),
        ];

        if ($tags != null  && is_array($tags) && !empty($tags))
        {
            $n = 1 ;
            foreach ($tags as $tag){
                $key = 'msgTag.' . $n;
                $params[$key]=$tag;
                $n += 1 ;
            }
        }

        $request = new PublishMessageRequest($params);

        try {
            $this->client->send($request);
        } catch (\Exception $e) {
            throw $e;
        }
    }
374831
def publish(self, topic, *args, **kwargs):
        
        assert topic is not None

        params = {
            "topic": topic,
            "args": args,
            "kwargs": kwargs
        }

        response = self._make_api_call("POST", self.url, json_params=params)
        return response["id"]
987551
function publish(conn, channel, indices, message) {
  var i
    , conn;
  for(i = 0;i < indices.length;i++) {
    conn = this._state.getClient(indices[i]);
    if(conn) {
      conn.write(message);
    }
  }
}
503764
def publish_tcp(self, topic, data, **kwargs):
        
        return self.__tcp_client.publish(topic, data, **kwargs)
390077
function publish (channel, ...args) {
    if (!isString(channel)) throw new TypeError(`${_debugStr}: .publish(channel, [...args]) channel MUST be a string`)
    if (~internalChannels.indexOf(channel)) {
      console.warn(`${_debugStr} channel '${channel}' is used internally and you cannot publish in it`)
      return node
    }
    if (!_pubConnection.connected) {
      console.warn(`${_debugStr} cannot publish on bus.`)
      return node
    }
    _pubConnection.publish(channel, ...args)
    return node
  }
1328403
def pub(topic_name, json_msg, repeat_rate=None, host=jps.env.get_master_host(), pub_port=jps.DEFAULT_PUB_PORT):
    '''
    '''
    pub = jps.Publisher(topic_name, host=host, pub_port=pub_port)
    time.sleep(0.1)
    if repeat_rate is None:
        pub.publish(json_msg)
    else:
        try:
            while True:
                pub.publish(json_msg)
                time.sleep(1.0 / repeat_rate)
        except KeyboardInterrupt:
            pass