Skip to content

refactor(amqp)!: migrate to go-amqp v1.x API#1226

Open
fxsml wants to merge 2 commits intocloudevents:mainfrom
fxsml:fix/amqp-migrate-v1
Open

refactor(amqp)!: migrate to go-amqp v1.x API#1226
fxsml wants to merge 2 commits intocloudevents:mainfrom
fxsml:fix/amqp-migrate-v1

Conversation

@fxsml
Copy link

@fxsml fxsml commented Jan 14, 2026

Summary

  • Fixes Support https://github.com/Azure/go-amqp stable version #1039 - AMQP protocol binding broken for 21 months due to replace directive not propagating to downstream users
  • Migrates from go-amqp v0.17.0 to v1.x (v1.5.1)
  • Simplifies API by using struct-based options instead of functional options
  • Adds comprehensive migration guide (MIGRATION.md)

Breaking Changes

The go-amqp v1.x API is fundamentally different from v0.17.0:

Before (v0.17.0) After (v1.x)
[]amqp.ConnOption{amqp.ConnSASLPlain(...)} &amqp.ConnOptions{SASLType: amqp.SASLTypePlain(...)}
[]amqp.SessionOption{} *amqp.SessionOptions{} or nil
Variadic functional options Struct pointers

See MIGRATION.md for complete migration guide.

Why This Fix Is Necessary

The replace directive in go.mod only applies to the main module, not to downstream dependencies. When users import the CloudEvents AMQP package, Go's MVS selects go-amqp v1.x (from other dependencies like Azure SDKs), causing compilation failures.

Test Plan

  • Unit tests pass: cd protocol/amqp/v2 && go test ./...
  • Integration tests with Azure Service Bus (set SERVICEBUS_CONNECTION env var)
  • Verified with example applications (before/after migration)

fxsml added 2 commits January 14, 2026 08:51
BREAKING CHANGE: This migration updates the AMQP protocol binding from
go-amqp v0.17.0 to v1.x with significant API changes.

Changes:
- Update to go-amqp v1.x (remove replace directive)
- Rename *Client types to *Conn to match go-amqp v1.x
- Rename NewProtocolFromClient → NewProtocolFromConn (and variants)
- Use struct-based options instead of functional options
- Remove non-functional WithConnSASLPlain, WithConnOptions, WithSessionOptions
- Simplify to WithSenderOptions and WithReceiverOptions only
- Add MIGRATION.md with upgrade guide and examples

See MIGRATION.md for detailed upgrade instructions.

Fixes cloudevents#1039

Signed-off-by: fxsml <[email protected]>
Add comprehensive integration tests for go-amqp v1.x migration:

- Direct AMQP connection with SASL Plain authentication
- CloudEvents protocol binding (NewProtocol, NewProtocolFromConn)
- Queue send/receive roundtrip with message verification
- Topic/subscription pub-sub pattern roundtrip
- Proper message acknowledgment with Finish()

Tests validate the migration works correctly with real Azure Service Bus.
Set SERVICEBUS_CONNECTION environment variable to run.

Signed-off-by: fxsml <[email protected]>
@fxsml fxsml requested a review from a team as a code owner January 14, 2026 08:46
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.

Support https://github.com/Azure/go-amqp stable version

1 participant