Example #1
0
func Producer(c, quit chan string, conn *stomp.Conn) {
	for {
		select {
		case c <- "msg sent":
			err := conn.Send(
				"/queue/test-1",           // destination
				"text/plain",              // content-type
				[]byte("Test message #1")) // body
			if err != nil {
				fmt.Println(err)
				return
			}
		case <-quit:
			fmt.Println("finish")
			return
		}
	}
}
Example #2
0
func ExampleConn_Send(c *stomp.Conn) error {
	// send with receipt and an optional header
	err := c.Send(
		"/queue/test-1",            // destination
		"text/plain",               // content-type
		[]byte("Message number 1"), // body
		stomp.SendOpt.Receipt,
		stomp.SendOpt.Header("expires", "2049-12-31 23:59:59"))
	if err != nil {
		return err
	}

	// send with no receipt and no optional headers
	err = c.Send("/queue/test-2", "application/xml",
		[]byte("<message>hello</message>"))
	if err != nil {
		return err
	}

	return nil
}