Add RabbitMQ.Client v7 support by migrating to async API #1384
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves the compatibility issue with RabbitMQ.Client v7.X by migrating the WorkflowCore.QueueProviders.RabbitMQ provider to use the new asynchronous API.
Problem
WorkflowCore failed to start when using RabbitMQ.Client v7.X with the error:
This occurred because RabbitMQ.Client v7 removed all synchronous
CreateConnection()methods and replaced them with asynchronousCreateConnectionAsync()methods.Solution
Package Update:
Connection Factory Migration:
connectionFactory.CreateConnection(name)→connectionFactory.CreateConnectionAsync(name, cancellationToken)connectionFactory.CreateConnection(hostnames, name)→connectionFactory.CreateConnectionAsync(hostnames, name, cancellationToken)IConnection RabbitMqConnectionFactory(...)→Task<IConnection> RabbitMqConnectionFactory(..., CancellationToken)Channel Operations Migration:
CreateModel()→CreateChannelAsync(CreateChannelOptions, CancellationToken)QueueDeclare()→QueueDeclareAsync()BasicPublish()→BasicPublishAsync()BasicGet()→BasicGetAsync()BasicQos()→BasicQosAsync()BasicAck()→BasicAckAsync()Close()→CloseAsync()Data Type Updates:
byte[]→ReadOnlyMemory<byte>for message bodiesIModel→IChannelinterfaceCompatibility
This change is fully backward compatible for WorkflowCore users. All public APIs remain the same - the migration to async operations is handled internally by the RabbitMQ provider.
Before (v6 API):
After (v7 API - same usage):
Testing
Fixes #1366.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.