Publish a message to a topic
484721
def pub(self, topic, message):
        ''''''
        return self.post('pub', params={'topic': topic}, data=message)
1077525
def publish(self, message_type, client_id, client_storage, *args, **kwargs):
        
        p = self.pack(message_type, client_id, client_storage, args, kwargs)
        self.client.publish(self.channel, p)
497565
final PublishResponse publish(String topic, List<PubsubMessage> messages) {

    PublishRequest request =
        PublishRequest.newBuilder().setTopic(topic).addAllMessages(messages).build();
    return publish(request);
  }
946291
def publish(self, topic, messages, key=None):
        

        if not isinstance(messages, list):
            messages = [messages]

        first = True
        success = False
        if key is None:
            key = int(time.time() * 1000)

        messages = [encodeutils.to_utf8(m) for m in messages]

        key = bytes(str(key), 'utf-8') if PY3 else str(key)

        while not success:
            try:
                self._producer.send_messages(topic, key, *messages)
                success = True
            except Exception:
                if first:
                    # This is a warning because of all the other warning and
                    # error messages that are logged in this case. This way
                    # someone looking at the log file can see the retry
                    log.warn("Failed send on topic {}, clear metadata and retry"
                             .format(topic))

                    # If Kafka is running in Kubernetes, the cached metadata
                    # contains the IP Address of the Kafka pod. If the Kafka
                    # pod has restarted, the IP Address will have changed
                    # which would have caused the first publish to fail. So,
                    # clear the cached metadata and retry the publish
                    self._kafka.reset_topic_metadata(topic)
                    first = False
                    continue
                log.exception('Error publishing to {} topic.'.format(topic))
                raise
566599
public void publishToAll(String message) {
		StringBuffer buf = new StringBuffer(message);
		synchronized (clientSessions) {
			System.out.println("send message '" + message + "' to " + clientSessions.size() + " clients");

			Iterator<Session> it = clientSessions.iterator();
			while (it.hasNext()) {
				Session session = it.next();
				try {
					session.getRemote().sendString(buf.toString());
				} catch (IOException exception) {
					clientSessions.remove(session);
					it = clientSessions.iterator();
					try {
						session.close();
					} catch (Exception e) {
					}
				}
			}
		}

	}
1035878
def push_to_topic(dst, dat, qos=0, retain=False, cfgs=None):
    
    cfg_amqt = {
        'hostname': cfgs['hostname'],
        'port': cfgs['port'],
        'username': cfgs['username'],
        'password': cfgs['password'],
    }

    msg = {
        'topic': dst,
        'payload': dat,
        'qos': qos,
        'retain': retain,
    }
    try:
        Publisher(cfg_amqt).run(msg)
        return True
    except Exception as err:
        log.error('push to amqt: {}'.format(err))
        return False
562691
def _publish_status(self, slug, data):
        

        status_topic = self.topics.prefix + 'devices/{}/data/status'.format(slug)

        self._logger.debug("Publishing status message: (topic=%s) (message=%s)", status_topic, str(data))
        self.client.publish(status_topic, data)
332211
public IMessagePublication publish(T message) {
        IMessagePublication publication = createMessagePublication(message);
        try {
            publication.execute();
        } catch (Throwable e) {
            handlePublicationError(new PublicationError()
                    .setMessage("Error during publication of message")
                    .setCause(e)
                    .setPublication(publication));
        }
        finally{
            return publication;
        }
    }
1142379
def publish(topic, payload = '', retain = false, qos = 0)
      raise ArgumentError, 'Topic name cannot be nil' if topic.nil?
      raise ArgumentError, 'Topic name cannot be empty' if topic.empty?

      packet = MQTT::Packet::Publish.new(
        :id => next_packet_id,
        :qos => qos,
        :retain => retain,
        :topic => topic,
        :payload => payload
      )

      # Send the packet
      res = send_packet(packet)

      return if qos.zero?

      Timeout.timeout(@ack_timeout) do
        while connected?
          @pubacks_semaphore.synchronize do
            return res if @pubacks.delete(packet.id)
          end
          # FIXME: make threads communicate with each other, instead of polling
          # (using a pipe and select ?)
          sleep 0.01
        end
      end

      -1
    end
31892
async def publish(self, message):
        
        try:
            self.write_message(dict(data=message))
        except WebSocketClosedError:
            self._close()
953409
private void sendOrPublishMessage(Message message) {
        if (endpointConfiguration.isPubSubDomain()) {
            if (log.isDebugEnabled()) {
                log.debug("Publish Vert.x event bus message to address: '" + endpointConfiguration.getAddress() + "'");
            }
            vertx.eventBus().publish(endpointConfiguration.getAddress(), message.getPayload());
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Sending Vert.x event bus message to address: '" + endpointConfiguration.getAddress() + "'");
            }
            vertx.eventBus().send(endpointConfiguration.getAddress(), message.getPayload());
        }
    }
1195698
def publish(self, topic, *args, **kwargs):
        
        return self._async_session.publish(topic, *args, **kwargs)
230643
def publish_state(self, state):
        
        message = json.dumps({'state': {'reported': state}})
        self.client.publish(self.topic, message)
        self._state = state
609093
function publish (channel, ...args) {
    _publishStream.emit('message', channel, uniqueId(`${node.name}_`), ...args)
  }
18164
def publish(self, message, exchange, routing_key, mandatory=None,
            immediate=None, headers=None):
        """"""
        body, properties = message

        if headers:
            properties.headers = headers

        ret = self.channel.basic_publish(body=body,
                                         properties=properties,
                                         exchange=exchange,
                                         routing_key=routing_key,
                                         mandatory=mandatory,
                                         immediate=immediate)
        if mandatory or immediate:
            self.close()
782886
def __make_message(self, topic, content):
        
        return {"uid": str(uuid.uuid4()).replace('-', '').upper(),
                "topic": topic,
                "content": content}
478039
final PublishResponse publish(
      ProjectTopicName topic, List<PubsubMessage> messages) {

    PublishRequest request =
        PublishRequest.newBuilder()
            .setTopic(topic == null ? null : topic.toString())
            .addAllMessages(messages)
            .build();
    return publish(request);
  }