代码拉取完成,页面将自动刷新
package main
import (
"gitee.com/flash520/utils/rabbitmq/simple"
"gitee.com/flash520/utils/rabbitmq/test/handler"
"gitee.com/flash520/utils/response"
"github.com/gin-contrib/pprof"
"github.com/gin-gonic/gin"
)
var (
producer, err = simple.NewSimpleProducer(
"amqp://guest:guest@localhost:5672/", "test", "test",
)
consumer, _ = simple.NewSimpleConsumer(
"amqp://guest:guest@127.0.0.1:5672/", "test", "test", 2,
)
)
func init() {
consumer.Declare()
go receive()
}
func main() {
r := gin.Default()
pprof.Register(r)
r.GET("/send/:id", send)
_ = r.Run(":80")
}
func send(c *gin.Context) {
msg := c.Param("id")
err = producer.Send(msg, "", "")
if err != nil {
response.Fail(c, 0, err, nil)
return
}
response.Success(c, 1, "success", nil)
}
func receive() {
h := handler.Handler{}
consumer.Received(false, h.Receive)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。