Skip to content

Remove IAsyncConnectionFactory #933

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

Merged
merged 1 commit into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/RabbitMQ.Client/client/api/ConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace RabbitMQ.Client
///"amqp://foo/" (note the trailing slash) also represent the
///default virtual host. The latter issue means that virtual
///hosts with an empty name are not addressable. </para></remarks>
public sealed class ConnectionFactory : ConnectionFactoryBase, IAsyncConnectionFactory
public sealed class ConnectionFactory : ConnectionFactoryBase, IConnectionFactory
{
/// <summary>
/// Default value for the desired maximum channel number. Default: 2047.
Expand Down
46 changes: 0 additions & 46 deletions projects/RabbitMQ.Client/client/api/IAsyncConnectionFactory.cs

This file was deleted.

6 changes: 6 additions & 0 deletions projects/RabbitMQ.Client/client/api/IConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ public interface IConnectionFactory
/// </summary>
TimeSpan ContinuationTimeout { get; set; }

/// <summary>
/// Gets or sets a value indicating whether an asynchronous consumer dispatcher which is compatible with <see cref="IAsyncBasicConsumer"/> is used.
/// </summary>
/// <value><see langword="true" /> if an asynchronous consumer dispatcher which is compatible with <see cref="IAsyncBasicConsumer"/> is used; otherwise, <see langword="false" />.</value>
bool DispatchConsumersAsync { get; set; }

/// <summary>
/// Set to a value greater than one to enable concurrent processing. For a concurrency greater than one <see cref="IBasicConsumer"/>
/// will be offloaded to the worker thread pool so it is important to choose the value for the concurrency wisely to avoid thread pool overloading.
Expand Down
13 changes: 4 additions & 9 deletions projects/RabbitMQ.Client/client/impl/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,9 @@ public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHa
_factory = factory;
_frameHandler = frameHandler;

if (factory is IAsyncConnectionFactory asyncConnectionFactory && asyncConnectionFactory.DispatchConsumersAsync)
{
ConsumerWorkService = new AsyncConsumerWorkService(factory.ConsumerDispatchConcurrency);
}
else
{
ConsumerWorkService = new ConsumerWorkService(factory.ConsumerDispatchConcurrency);
}
ConsumerWorkService = factory.DispatchConsumersAsync
? new AsyncConsumerWorkService(factory.ConsumerDispatchConcurrency)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also wondering if there is a case to be made to simply remove the non-async consumers from 7.0 and keep them async-only?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that is one discussion topic I was hopping to have in the meeting :D, then write it down and announce it to the community

Copy link
Contributor

Choose a reason for hiding this comment

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

We can consider it.

: new ConsumerWorkService(factory.ConsumerDispatchConcurrency);

_sessionManager = new SessionManager(this, 0);
_session0 = new MainSession(this) { Handler = NotifyReceivedCloseOk };
Expand Down Expand Up @@ -154,7 +149,7 @@ public event EventHandler<ShutdownEventArgs> ConnectionShutdown
}
}



public event EventHandler<EventArgs> ConnectionUnblocked;

Expand Down
7 changes: 2 additions & 5 deletions projects/Unit/APIApproval.Approve.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace RabbitMQ.Client
public BinaryTableValue(byte[] bytes) { }
public byte[] Bytes { get; set; }
}
public sealed class ConnectionFactory : RabbitMQ.Client.ConnectionFactoryBase, RabbitMQ.Client.IAsyncConnectionFactory, RabbitMQ.Client.IConnectionFactory
public sealed class ConnectionFactory : RabbitMQ.Client.ConnectionFactoryBase, RabbitMQ.Client.IConnectionFactory
{
public const ushort DefaultChannelMax = 2047;
public const uint DefaultFrameMax = 0u;
Expand Down Expand Up @@ -221,10 +221,6 @@ namespace RabbitMQ.Client
System.Threading.Tasks.Task HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, RabbitMQ.Client.IBasicProperties properties, System.ReadOnlyMemory<byte> body);
System.Threading.Tasks.Task HandleModelShutdown(object model, RabbitMQ.Client.ShutdownEventArgs reason);
}
public interface IAsyncConnectionFactory : RabbitMQ.Client.IConnectionFactory
{
bool DispatchConsumersAsync { get; set; }
}
public interface IAuthMechanism
{
byte[] handleChallenge(byte[] challenge, RabbitMQ.Client.IConnectionFactory factory);
Expand Down Expand Up @@ -338,6 +334,7 @@ namespace RabbitMQ.Client
string ClientProvidedName { get; set; }
int ConsumerDispatchConcurrency { get; set; }
System.TimeSpan ContinuationTimeout { get; set; }
bool DispatchConsumersAsync { get; set; }
System.TimeSpan HandshakeContinuationTimeout { get; set; }
string Password { get; set; }
ushort RequestedChannelMax { get; set; }
Expand Down