예제 #1
0
func main() {
	e := env.Init()
	r := coelho.Rabbit{}
	r.Exchange = e.Exchange
	r.ExchangeType = e.ExchangeType
	r.Durable = e.Durable
	r.Delete = e.Delete
	r.Exclusive = e.Exclusive
	r.NoWait = e.NoWait
	r.QoS = 100
	flag.Parse()
	go dispatch(e, r, "offer.click")
	go dispatch(e, r, "catalog.view")
	<-ctx.Done()
}
예제 #2
0
func dispatch(e env.Vars, r coelho.Rabbit, rk string) {
	lines := make(chan amqp.Delivery, r.QoS)
	// set the right routing key
	// monitor
	go func() {
		for {
			log.Infof("message buffer:%v, used:%v", cap(lines), len(lines))
			//dev
			time.Sleep(30 * time.Second)
		}
	}()
	// Subscribe
	go func() {
		for {
			r.Subscribe(ctx, r.Redial(ctx, e.RabbitMqAddres), lines, rk, &read)
		}
		done()
	}()
	// process
	bunchedLines := coelho.Bunch(ctx, lines, 100, 100)
	go ack(os.Stdout, bunchedLines)
	<-ctx.Done()
}
예제 #3
0
func main() {
	e := env.Init()
	r := coelho.Rabbit{}
	r.Exchange = e.Exchange
	r.ExchangeType = e.ExchangeType
	r.Durable = e.Durable
	r.Delete = e.Delete
	r.Exclusive = e.Exclusive
	r.NoWait = e.NoWait
	flag.Parse()
	go func() {
		r.Publish(ctx, r.Redial(ctx, e.RabbitMqAddres), read(os.Stdin), "all")
		done()
	}()

	<-ctx.Done()
}