The streadway/amqp client doesn't err out or terminate the channel when publishing to an exchange resource that should be not found. Although one could argue the language is attempt to publish making it ambiguous. I am not sure how we would do that other than caching the full active topology queried from the server.
// TestBasicPublishToNonExistentExchange tests what happen when a publish to exchange
// that doesn't exist also doesn't error.
func TestBasicPublishToNonExistentExchange(t *testing.T) {
defer leaktest.Check(t)()
letter := tcr.CreateMockLetter("DoesNotExist", "TcrTestQueue", nil)
amqpConn, err := amqp.Dial(Seasoning.PoolConfig.URI)
if err != nil {
t.Error(t, err)
return
}
amqpChan, err := amqpConn.Channel()
if err != nil {
t.Error(t, err)
return
}
err = amqpChan.Publish(
letter.Envelope.Exchange,
letter.Envelope.RoutingKey,
letter.Envelope.Mandatory,
letter.Envelope.Immediate,
amqp.Publishing{
ContentType: letter.Envelope.ContentType,
Body: letter.Body,
MessageId: letter.LetterID.String(),
Timestamp: time.Now().UTC(),
AppId: "TCR-Test",
})
if err != nil {
t.Error(t, err)
return
}
amqpChan.Close()
amqpConn.Close()
}
The above exchange does not exist, Mandatory/Immediate flags are both false here, but same result on true. Does not return err.
Work around is to declare resource and perform any bindings before using it obviously. This was obviously a developer's mistake, but noticed that it should be sending an error to give feedback to the user.
This doesn't appear to be working per the spec.
The streadway/amqp client doesn't
err
out or terminate thechannel
when publishing to an exchange resource that should be not found. Although one could argue the language is attempt to publish making it ambiguous. I am not sure how we would do that other than caching the full active topology queried from the server.The above
exchange
does not exist, Mandatory/Immediate flags are both false here, but same result on true. Does not returnerr
.original source: https://github.com/houseofcat/turbocookedrabbit/blob/110270e1131d6948d2090fa592ed0c4cb24fea8c/v2/tests/main_publisher_test.go#L76
relatable issue from my repo: https://github.com/houseofcat/turbocookedrabbit/issues/15
Confirmed on Server v3.8.7 / 3.8.14.
Work around is to declare resource and perform any bindings before using it obviously. This was obviously a developer's mistake, but noticed that it should be sending an error to give feedback to the user.