1 Star 1 Fork 0

flash520/utils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 852 Bytes
一键复制 编辑 原始数据 按行查看 历史
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)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/flash520/utils.git
git@gitee.com:flash520/utils.git
flash520
utils
utils
v1.0.4

搜索帮助