1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

Use direct reply queue

This commit is contained in:
Asim 2015-11-08 23:16:14 +00:00
parent 55ef1d4903
commit 3cf90d7825
2 changed files with 11 additions and 14 deletions

View File

@ -18,12 +18,11 @@ var (
)
type rabbitMQConn struct {
Connection *amqp.Connection
Channel *rabbitMQChannel
ExchangeChannel *rabbitMQChannel
notify chan bool
exchange string
url string
Connection *amqp.Connection
Channel *rabbitMQChannel
notify chan bool
exchange string
url string
connected bool
@ -111,10 +110,6 @@ func (r *rabbitMQConn) tryToConnect() error {
return err
}
r.Channel.DeclareExchange(r.exchange)
r.ExchangeChannel, err = newRabbitChannel(r.Connection)
if err != nil {
return err
}
return nil
}
@ -143,5 +138,5 @@ func (r *rabbitMQConn) Consume(queue string) (<-chan amqp.Delivery, error) {
}
func (r *rabbitMQConn) Publish(exchange, key string, msg amqp.Publishing) error {
return r.ExchangeChannel.Publish(exchange, key, msg)
return r.Channel.Publish(exchange, key, msg)
}

View File

@ -12,6 +12,10 @@ import (
"github.com/myodc/go-micro/transport"
)
const (
directReplyQueue = "amq.rabbitmq.reply-to"
)
type rmqtport struct {
conn *rabbitMQConn
addrs []string
@ -236,12 +240,10 @@ func (r *rmqtport) Listen(addr string) (transport.Listener, error) {
}
func NewTransport(addrs []string, opt ...transport.Option) transport.Transport {
id, _ := uuid.NewV4()
return &rmqtport{
conn: newRabbitMQConn("", addrs),
addrs: addrs,
replyTo: id.String(),
replyTo: directReplyQueue,
inflight: make(map[string]chan amqp.Delivery),
}
}