Skip to content

Commit

Permalink
* Make default RMQ max message size constant Internal
Browse files Browse the repository at this point in the history
* Ensure that maximum max message size is not overriden
  • Loading branch information
lukebakken committed May 16, 2024
1 parent 0b34430 commit 6505464
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
3 changes: 1 addition & 2 deletions projects/RabbitMQ.Client/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const RabbitMQ.Client.ConnectionFactory.DefaultChannelMax = 2047 -> ushort
const RabbitMQ.Client.ConnectionFactory.DefaultFrameMax = 0 -> uint
const RabbitMQ.Client.ConnectionFactory.DefaultMaxInboundMessageBodySize = 67108864 -> uint
const RabbitMQ.Client.ConnectionFactory.DefaultPass = "guest" -> string
const RabbitMQ.Client.ConnectionFactory.DefaultRabbitMqMaxInboundMessageBodySize = 134217728 -> uint
const RabbitMQ.Client.ConnectionFactory.DefaultUser = "guest" -> string
const RabbitMQ.Client.ConnectionFactory.DefaultVHost = "/" -> string
const RabbitMQ.Client.Constants.AccessRefused = 403 -> int
Expand Down Expand Up @@ -884,7 +883,7 @@ virtual RabbitMQ.Client.TcpClientAdapter.ReceiveTimeout.set -> void
~const RabbitMQ.Client.RabbitMQActivitySource.PublisherSourceName = "RabbitMQ.Client.Publisher" -> string
~const RabbitMQ.Client.RabbitMQActivitySource.SubscriberSourceName = "RabbitMQ.Client.Subscriber" -> string
~override RabbitMQ.Client.Events.EventingBasicConsumer.HandleBasicDeliverAsync(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, RabbitMQ.Client.ReadOnlyBasicProperties properties, System.ReadOnlyMemory<byte> body) -> System.Threading.Tasks.Task
~RabbitMQ.Client.AmqpTcpEndpoint.AmqpTcpEndpoint(string hostName, int portOrMinusOne, RabbitMQ.Client.SslOption ssl, uint rabbitMqMaxMessageSize) -> void
~RabbitMQ.Client.AmqpTcpEndpoint.AmqpTcpEndpoint(string hostName, int portOrMinusOne, RabbitMQ.Client.SslOption ssl, uint maxInboundMessageBodySize) -> void
~RabbitMQ.Client.ConnectionFactory.CreateConnectionAsync(RabbitMQ.Client.IEndpointResolver endpointResolver, string clientProvidedName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<RabbitMQ.Client.IConnection>
~RabbitMQ.Client.ConnectionFactory.CreateConnectionAsync(string clientProvidedName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<RabbitMQ.Client.IConnection>
~RabbitMQ.Client.ConnectionFactory.CreateConnectionAsync(System.Collections.Generic.IEnumerable<RabbitMQ.Client.AmqpTcpEndpoint> endpoints, string clientProvidedName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<RabbitMQ.Client.IConnection>
Expand Down
9 changes: 4 additions & 5 deletions projects/RabbitMQ.Client/client/api/AmqpTcpEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,15 @@ public class AmqpTcpEndpoint
/// <param name="hostName">Hostname.</param>
/// <param name="portOrMinusOne"> Port number. If the port number is -1, the default port number will be used.</param>
/// <param name="ssl">Ssl option.</param>
/// <param name="rabbitMqMaxMessageSize">Maximum message size from RabbitMQ. <see cref="ConnectionFactory.MaxInboundMessageBodySize"/>. It defaults to
/// MaximumMaxMessageSize if the parameter is greater than MaximumMaxMessageSize.</param>
/// <param name="maxInboundMessageBodySize">Maximum message size from RabbitMQ.</param>
public AmqpTcpEndpoint(string hostName, int portOrMinusOne, SslOption ssl,
uint rabbitMqMaxMessageSize)
uint maxInboundMessageBodySize)
{
HostName = hostName;
_port = portOrMinusOne;
Ssl = ssl;
_maxInboundMessageBodySize = Math.Min(rabbitMqMaxMessageSize,
ConnectionFactory.DefaultRabbitMqMaxInboundMessageBodySize);
_maxInboundMessageBodySize = Math.Min(maxInboundMessageBodySize,
InternalConstants.DefaultRabbitMqMaxInboundMessageBodySize);
}

/// <summary>
Expand Down
7 changes: 0 additions & 7 deletions projects/RabbitMQ.Client/client/api/ConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,6 @@ public sealed class ConnectionFactory : ConnectionFactoryBase, IConnectionFactor
/// </summary>
public const uint DefaultMaxInboundMessageBodySize = 1_048_576 * 64;

/// <summary>
/// Largest message size, in bytes, allowed in RabbitMQ.
/// Note: <code>rabbit.max_message_size</code> setting (https://www.rabbitmq.com/configure.html)
/// configures the largest message size which should be lower than this maximum of 128MiB.
/// </summary>
public const uint DefaultRabbitMqMaxInboundMessageBodySize = 1_048_576 * 128;

/// <summary>
/// Default value for desired heartbeat interval. Default is 60 seconds,
/// TimeSpan.Zero means "heartbeats are disabled".
Expand Down
7 changes: 7 additions & 0 deletions projects/RabbitMQ.Client/client/api/InternalConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,12 @@ internal static class InternalConstants
{
internal static readonly TimeSpan DefaultConnectionAbortTimeout = TimeSpan.FromSeconds(5);
internal static readonly TimeSpan DefaultConnectionCloseTimeout = TimeSpan.FromSeconds(30);

/// <summary>
/// Largest message size, in bytes, allowed in RabbitMQ.
/// Note: <code>rabbit.max_message_size</code> setting (https://www.rabbitmq.com/configure.html)
/// configures the largest message size which should be lower than this maximum of 128MiB.
/// </summary>
internal const uint DefaultRabbitMqMaxInboundMessageBodySize = 1_048_576 * 128;
}
}
5 changes: 3 additions & 2 deletions projects/Test/Integration/TestConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ public async Task TestCreateConnectionUsesValidEndpointWhenMultipleSupplied()
[Fact]
public void TestCreateAmqpTCPEndPointOverridesMaxMessageSizeWhenGreaterThanMaximumAllowed()
{
_ = new AmqpTcpEndpoint("localhost", -1, new SslOption(),
ConnectionFactory.DefaultRabbitMqMaxInboundMessageBodySize);
var ep = new AmqpTcpEndpoint("localhost", -1, new SslOption(),
2 * InternalConstants.DefaultRabbitMqMaxInboundMessageBodySize);
Assert.Equal(InternalConstants.DefaultRabbitMqMaxInboundMessageBodySize, ep.MaxInboundMessageBodySize);
}

[Fact]
Expand Down

0 comments on commit 6505464

Please sign in to comment.