|
|
|
@ -28,9 +28,13 @@ type Config struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// InitRabbitmq @Title 初始化rabbitmq
|
|
|
|
|
func InitRabbitmq(config Config) (err error) {
|
|
|
|
|
func InitRabbitmq(config Config) error {
|
|
|
|
|
Rabbitmq.config = config
|
|
|
|
|
return getConn()
|
|
|
|
|
err := getConn()
|
|
|
|
|
if err != nil && Rabbitmq.config.ReConn {
|
|
|
|
|
go reConn()
|
|
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Title 获取连接
|
|
|
|
@ -106,9 +110,11 @@ func (r *rabbitmq) Publish(exchangeName, msg string, delay ...int64) error {
|
|
|
|
|
false, //强制为
|
|
|
|
|
false, //立即
|
|
|
|
|
amqp.Publishing{
|
|
|
|
|
ContentType: "text/plain",
|
|
|
|
|
Body: []byte(msg),
|
|
|
|
|
Headers: header,
|
|
|
|
|
ContentType: "text/plain",
|
|
|
|
|
Body: []byte(msg),
|
|
|
|
|
DeliveryMode: amqp.Persistent,
|
|
|
|
|
Timestamp: time.Now(),
|
|
|
|
|
Headers: header,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|