Skip to content

Add default queue implementation#85

Merged
Gsantomaggio merged 5 commits intomainfrom
feat/add_default_queue_declaration
Feb 13, 2026
Merged

Add default queue implementation#85
Gsantomaggio merged 5 commits intomainfrom
feat/add_default_queue_declaration

Conversation

@Gsantomaggio
Copy link
Copy Markdown
Member

@Gsantomaggio Gsantomaggio commented Feb 13, 2026

Adds a “default queue” specification to the RabbitMQ AMQP management client so callers can declare queues without explicitly setting x-queue-type, letting the server/vhost configuration decide the queue type.

Changes:

  • Introduces DefaultQueueSpecification implementing IQueueSpecification without specifying a queue type argument.
  • Updates topology recovery to map unknown/unspecified queue types to DefaultQueueSpecification.
  • Adds an integration test for declaring a queue using DefaultQueueSpecification.

Fixes #83

Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
@Gsantomaggio Gsantomaggio added this to the 0.6.0 milestone Feb 13, 2026
@Gsantomaggio Gsantomaggio self-assigned this Feb 13, 2026
@Gsantomaggio Gsantomaggio added the enhancement New feature or request label Feb 13, 2026
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a “default queue” specification to the RabbitMQ AMQP management client so callers can declare queues without explicitly setting x-queue-type, letting the server/vhost configuration decide the queue type.

Changes:

  • Introduces DefaultQueueSpecification implementing IQueueSpecification without specifying a queue type argument.
  • Updates topology recovery to map unknown/unspecified queue types to DefaultQueueSpecification.
  • Adds an integration test for declaring a queue using DefaultQueueSpecification.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
pkg/rabbitmqamqp/entities.go Adds DefaultQueueSpecification and expands IQueueSpecification documentation.
pkg/rabbitmqamqp/amqp_queue_test.go Adds a test that declares a queue using DefaultQueueSpecification.
pkg/rabbitmqamqp/amqp_connection_recovery.go Adds a default branch to recover queues with an unspecified/unknown type using DefaultQueueSpecification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/rabbitmqamqp/entities.go Outdated
Comment on lines +122 to +128
default:
return &DefaultQueueSpecification{
Name: q.queueName,
IsAutoDelete: *q.autoDelete,
IsExclusive: *q.exclusive,
Arguments: q.arguments,
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the new default branch, toIQueueSpecification dereferences q.autoDelete and q.exclusive, but queueRecoveryRecord.autoDelete/exclusive are only populated for Classic queues in AmqpManagement.DeclareQueue. For DefaultQueueSpecification records these pointers will be nil, causing a panic during topology recovery. Consider either storing autoDelete/exclusive for default queues as well, or handling nil pointers here (e.g., defaulting to false).

Copilot uses AI. Check for mistakes.
Comment on lines +266 to +267
// the default value for queue type is classic
Expect(queueInfo.Type()).To(Equal(Classic))
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion makes the test environment-dependent: RabbitMQ can be configured per-vhost to default queue type to quorum instead of classic when no x-queue-type is provided. To avoid flakiness, assert that no explicit x-queue-type was set (or only assert the DLX args), rather than hard-coding Classic here.

Suggested change
// the default value for queue type is classic
Expect(queueInfo.Type()).To(Equal(Classic))
// ensure no explicit queue type was set; actual default depends on broker configuration
Expect(queueInfo.arguments).NotTo(HaveKey("x-queue-type"))

Copilot uses AI. Check for mistakes.
Comment on lines +264 to +265
Expect(queueInfo.arguments["x-dead-letter-exchange"]).To(Equal("dead-letter-exchange"))
Expect(queueInfo.arguments["x-dead-letter-routing-key"]).To(Equal("dead-letter-routing-key"))
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of this file uses the public accessor queueInfo.Arguments() for argument assertions; accessing the unexported field queueInfo.arguments directly makes the test more brittle to internal refactors. Prefer using Arguments() here for consistency and encapsulation.

Suggested change
Expect(queueInfo.arguments["x-dead-letter-exchange"]).To(Equal("dead-letter-exchange"))
Expect(queueInfo.arguments["x-dead-letter-routing-key"]).To(Equal("dead-letter-routing-key"))
Expect(queueInfo.Arguments()["x-dead-letter-exchange"]).To(Equal("dead-letter-exchange"))
Expect(queueInfo.Arguments()["x-dead-letter-routing-key"]).To(Equal("dead-letter-routing-key"))

Copilot uses AI. Check for mistakes.
Gsantomaggio and others added 3 commits February 13, 2026 12:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
…tmq/rabbitmq-amqp-go-client into feat/add_default_queue_declaration
@Gsantomaggio Gsantomaggio merged commit 80af0df into main Feb 13, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't declare a queue without specify the type

2 participants