有关Go-Rabbitmq断线重连组件[go-amqp]

    由于博主暂未发现go-amqp库实现连接池与断线重连,近期基于Amqp二次封装,已支持断线重连,异常重连...具体看代码吧~

    现在每个服务一个连接与通道,如果需要一起扩展,可以联系....

    Git地址 : https://github.com/billmi/go-rabbit

 

    

package main

import (
	"go-rabbit/rabbit"
)

/*
	支持断线重连
	失败重发
    @author : Bill
*/
func main() {
	var(
		addr = "amqp://guest:guest@localhost:5672/"
		queue = "testQueue"
		exchange = "test_exchange"
		routerKey = "/test"
		msg = "test1!"

		//delay
		delayQueue = "delay_queue"
		delayExchange = "delay_exchange"
		delayRouterKey = "delay_exchange"
		prefix = "v1_prefix"
		sep = "_"
		eType = "F"
		_ttl = 60 * 1000
	)

	var rabbitProduct1 = rabbit.NewRabbitProduct(addr,_ttl,prefix,sep,delayExchange,delayQueue,delayRouterKey)
	//注册回收
	go rabbitProduct1.InitDefdelay(false)
	go rabbitProduct1.InitDefdelay(true)
	go rabbitProduct1.RegisterDelayWithPreFix("delay_queue","delay_exchange","delay_exchange")

	// ttl 为  设置死信回收时间  >0 则回收
	rabbitProduct1.PubMessage(true,eType,queue,exchange,routerKey,msg,rabbitProduct1.GetBool(1),rabbitProduct1.GetBool(0),_ttl)

}

 

你可能感兴趣的:(go,各种小总结,go-amqp)