Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amqp Spec 0.9.1 Deviation - Publishing To Non-Existent Exchanges #504

Open
houseofcat opened this issue Apr 19, 2021 · 0 comments
Open

Amqp Spec 0.9.1 Deviation - Publishing To Non-Existent Exchanges #504

houseofcat opened this issue Apr 19, 2021 · 0 comments

Comments

@houseofcat
Copy link

houseofcat commented Apr 19, 2021

This doesn't appear to be working per the spec.

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.

original source:
https://github.com/houseofcat/turbocookedrabbit/blob/110270e1131d6948d2090fa592ed0c4cb24fea8c/v2/tests/main_publisher_test.go#L76

relatable issue from my repo:
houseofcat/turbocookedrabbit#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant