Use direct reply queue
This commit is contained in:
parent
55ef1d4903
commit
3cf90d7825
@ -20,7 +20,6 @@ var (
|
|||||||
type rabbitMQConn struct {
|
type rabbitMQConn struct {
|
||||||
Connection *amqp.Connection
|
Connection *amqp.Connection
|
||||||
Channel *rabbitMQChannel
|
Channel *rabbitMQChannel
|
||||||
ExchangeChannel *rabbitMQChannel
|
|
||||||
notify chan bool
|
notify chan bool
|
||||||
exchange string
|
exchange string
|
||||||
url string
|
url string
|
||||||
@ -111,10 +110,6 @@ func (r *rabbitMQConn) tryToConnect() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r.Channel.DeclareExchange(r.exchange)
|
r.Channel.DeclareExchange(r.exchange)
|
||||||
r.ExchangeChannel, err = newRabbitChannel(r.Connection)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
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 {
|
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"
|
"github.com/myodc/go-micro/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
directReplyQueue = "amq.rabbitmq.reply-to"
|
||||||
|
)
|
||||||
|
|
||||||
type rmqtport struct {
|
type rmqtport struct {
|
||||||
conn *rabbitMQConn
|
conn *rabbitMQConn
|
||||||
addrs []string
|
addrs []string
|
||||||
@ -236,12 +240,10 @@ func (r *rmqtport) Listen(addr string) (transport.Listener, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewTransport(addrs []string, opt ...transport.Option) transport.Transport {
|
func NewTransport(addrs []string, opt ...transport.Option) transport.Transport {
|
||||||
id, _ := uuid.NewV4()
|
|
||||||
|
|
||||||
return &rmqtport{
|
return &rmqtport{
|
||||||
conn: newRabbitMQConn("", addrs),
|
conn: newRabbitMQConn("", addrs),
|
||||||
addrs: addrs,
|
addrs: addrs,
|
||||||
replyTo: id.String(),
|
replyTo: directReplyQueue,
|
||||||
inflight: make(map[string]chan amqp.Delivery),
|
inflight: make(map[string]chan amqp.Delivery),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user