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:
parent
55ef1d4903
commit
3cf90d7825
@ -20,7 +20,6 @@ var (
|
||||
type rabbitMQConn struct {
|
||||
Connection *amqp.Connection
|
||||
Channel *rabbitMQChannel
|
||||
ExchangeChannel *rabbitMQChannel
|
||||
notify chan bool
|
||||
exchange string
|
||||
url string
|
||||
@ -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)
|
||||
}
|
||||
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user