Example #1
0
File: queue.go Project: jmanero/nsq
func WriteMessageToBackend(buf *bytes.Buffer, msg *nsq.Message, bq BackendQueue) error {
	buf.Reset()
	err := msg.Write(buf)
	if err != nil {
		return err
	}
	err = bq.Put(buf.Bytes())
	if err != nil {
		return err
	}
	return nil
}
Example #2
0
func (p *ProtocolV2) SendMessage(client *ClientV2, msg *nsq.Message, buf *bytes.Buffer) error {
	if *verbose {
		log.Printf("PROTOCOL(V2): writing msg(%s) to client(%s) - %s",
			msg.Id, client, msg.Body)
	}

	buf.Reset()
	err := msg.Write(buf)
	if err != nil {
		return err
	}

	client.Channel.StartInFlightTimeout(msg, client)
	client.SendingMessage()

	err = p.Send(client, nsq.FrameTypeMessage, buf.Bytes())
	if err != nil {
		return err
	}

	return nil
}