Skip to content

feat: use exchange mechanism#72

Merged
cbartz merged 15 commits into
mainfrom
feat/use-exchange-ISD-4838
Jan 8, 2026
Merged

feat: use exchange mechanism#72
cbartz merged 15 commits into
mainfrom
feat/use-exchange-ISD-4838

Conversation

@cbartz

@cbartz cbartz commented Jan 5, 2026

Copy link
Copy Markdown
Collaborator

Overview

Use an explicit exchange instead of the default exchange for publishing messages.

The publisher (webhook-gateway) will now only declare a an exchange (with type direct).
The consumer (planner) will declare the queue and bind the exchange to the queue. To avoid errors when the exchange is not declared yet (e.g. the webhook-gateway has not been deployed yet), it will again declare the exchange. This is safe, as it is an idempotent operation.

Semantic change : If the webhook-gateway gets deployed without the planner, no messages will be stored, as there is no queue bound to the exchange.

Rationale

Having the publisher (webhook-gateway) publishing to an exchange without declaring the queue decouples the publisher from the queue and adheres to best practices.

Checklist

  • Changes comply with the project's coding standards and guidelines (see CONTRIBUTING.md and STYLE.md)
  • CONTRIBUTING.md has been updated upon changes to the contribution/development process (e.g. changes to the way tests are run)
  • Technical author has been assigned to review the PR in case of documentation changes (usually *.md files)

No need for TA, for minor technical doc update.

@cbartz cbartz left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

self-review

Comment thread cmd/planner/main_test.go
Comment thread internal/queue/config.go
Comment thread internal/queue/mock_test.go
Comment thread internal/queue/types.go

@cbartz cbartz left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

self-review

Comment thread internal/queue/config.go
Comment thread CONTRIBUTING.md
Comment thread CONTRIBUTING.md Outdated
@cbartz cbartz changed the title [WIP] feat: use exchange mechanism feat: use exchange mechanism Jan 6, 2026
@cbartz cbartz marked this pull request as ready for review January 6, 2026 12:35
@cbartz cbartz requested a review from Copilot January 6, 2026 12:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an explicit exchange mechanism for RabbitMQ message routing, replacing the default exchange pattern. The publisher (webhook-gateway) now declares only an exchange, while the consumer (planner) declares the queue and binds it to the exchange, following AMQP best practices for publisher-consumer decoupling.

Key Changes:

  • Introduced QueueConfig struct to centralize exchange, queue, and routing key configuration
  • Updated publisher to declare exchanges instead of queues
  • Modified consumer to declare queues and bind them to exchanges
  • Refactored mock objects into a dedicated test file for better organization

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/queue/config.go New file defining QueueConfig struct and default configuration values
internal/queue/types.go Refactored channel reset logic and added exchange/queue declaration and binding methods
internal/queue/producer.go Updated to use QueueConfig and publish to exchange instead of default exchange
internal/queue/consumer.go Modified to declare exchange, queue, and binding during channel setup
internal/queue/mock_test.go Consolidated mock implementations into a dedicated test file
internal/queue/producer_test.go Updated tests to use QueueConfig and new mock structure
internal/queue/consumer_test.go Updated tests to use QueueConfig and new mock structure
internal/queue/types_test.go Removed old mock implementations (moved to mock_test.go)
internal/planner/consumer.go Updated to accept QueueConfig parameter
cmd/webhook-gateway/main.go Updated to use DefaultQueueConfig()
cmd/webhook-gateway/webhook_test.go Added queue setup to ensure exchange and queue exist before publishing
cmd/planner/main.go Updated to use DefaultQueueConfig()
cmd/planner/main_test.go Updated to declare exchange and bind queue in tests
CONTRIBUTING.md Updated integration test commands with corrected syntax

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

Comment thread CONTRIBUTING.md Outdated
cbartz and others added 2 commits January 6, 2026 13:38
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread cmd/planner/main.go Outdated
Comment thread cmd/webhook-gateway/main.go

Copilot AI commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

@yanksyoon I've opened a new pull request, #78, to work on those changes. Once the pull request is ready, I'll request review from you.

@yanksyoon yanksyoon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@cbartz cbartz merged commit e81f169 into main Jan 8, 2026
34 checks passed
@cbartz cbartz deleted the feat/use-exchange-ISD-4838 branch January 8, 2026 06:17
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

Successfully merging this pull request may close these issues.

6 participants