Skip to content

Commit 6505464

Browse files
committed
* Make default RMQ max message size constant Internal
* Ensure that maximum max message size is not overriden
1 parent 0b34430 commit 6505464

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

projects/RabbitMQ.Client/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const RabbitMQ.Client.ConnectionFactory.DefaultChannelMax = 2047 -> ushort
55
const RabbitMQ.Client.ConnectionFactory.DefaultFrameMax = 0 -> uint
66
const RabbitMQ.Client.ConnectionFactory.DefaultMaxInboundMessageBodySize = 67108864 -> uint
77
const RabbitMQ.Client.ConnectionFactory.DefaultPass = "guest" -> string
8-
const RabbitMQ.Client.ConnectionFactory.DefaultRabbitMqMaxInboundMessageBodySize = 134217728 -> uint
98
const RabbitMQ.Client.ConnectionFactory.DefaultUser = "guest" -> string
109
const RabbitMQ.Client.ConnectionFactory.DefaultVHost = "/" -> string
1110
const RabbitMQ.Client.Constants.AccessRefused = 403 -> int
@@ -884,7 +883,7 @@ virtual RabbitMQ.Client.TcpClientAdapter.ReceiveTimeout.set -> void
884883
~const RabbitMQ.Client.RabbitMQActivitySource.PublisherSourceName = "RabbitMQ.Client.Publisher" -> string
885884
~const RabbitMQ.Client.RabbitMQActivitySource.SubscriberSourceName = "RabbitMQ.Client.Subscriber" -> string
886885
~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
887-
~RabbitMQ.Client.AmqpTcpEndpoint.AmqpTcpEndpoint(string hostName, int portOrMinusOne, RabbitMQ.Client.SslOption ssl, uint rabbitMqMaxMessageSize) -> void
886+
~RabbitMQ.Client.AmqpTcpEndpoint.AmqpTcpEndpoint(string hostName, int portOrMinusOne, RabbitMQ.Client.SslOption ssl, uint maxInboundMessageBodySize) -> void
888887
~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>
889888
~RabbitMQ.Client.ConnectionFactory.CreateConnectionAsync(string clientProvidedName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<RabbitMQ.Client.IConnection>
890889
~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>

projects/RabbitMQ.Client/client/api/AmqpTcpEndpoint.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,15 @@ public class AmqpTcpEndpoint
7070
/// <param name="hostName">Hostname.</param>
7171
/// <param name="portOrMinusOne"> Port number. If the port number is -1, the default port number will be used.</param>
7272
/// <param name="ssl">Ssl option.</param>
73-
/// <param name="rabbitMqMaxMessageSize">Maximum message size from RabbitMQ. <see cref="ConnectionFactory.MaxInboundMessageBodySize"/>. It defaults to
74-
/// MaximumMaxMessageSize if the parameter is greater than MaximumMaxMessageSize.</param>
73+
/// <param name="maxInboundMessageBodySize">Maximum message size from RabbitMQ.</param>
7574
public AmqpTcpEndpoint(string hostName, int portOrMinusOne, SslOption ssl,
76-
uint rabbitMqMaxMessageSize)
75+
uint maxInboundMessageBodySize)
7776
{
7877
HostName = hostName;
7978
_port = portOrMinusOne;
8079
Ssl = ssl;
81-
_maxInboundMessageBodySize = Math.Min(rabbitMqMaxMessageSize,
82-
ConnectionFactory.DefaultRabbitMqMaxInboundMessageBodySize);
80+
_maxInboundMessageBodySize = Math.Min(maxInboundMessageBodySize,
81+
InternalConstants.DefaultRabbitMqMaxInboundMessageBodySize);
8382
}
8483

8584
/// <summary>

projects/RabbitMQ.Client/client/api/ConnectionFactory.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ public sealed class ConnectionFactory : ConnectionFactoryBase, IConnectionFactor
111111
/// </summary>
112112
public const uint DefaultMaxInboundMessageBodySize = 1_048_576 * 64;
113113

114-
/// <summary>
115-
/// Largest message size, in bytes, allowed in RabbitMQ.
116-
/// Note: <code>rabbit.max_message_size</code> setting (https://www.rabbitmq.com/configure.html)
117-
/// configures the largest message size which should be lower than this maximum of 128MiB.
118-
/// </summary>
119-
public const uint DefaultRabbitMqMaxInboundMessageBodySize = 1_048_576 * 128;
120-
121114
/// <summary>
122115
/// Default value for desired heartbeat interval. Default is 60 seconds,
123116
/// TimeSpan.Zero means "heartbeats are disabled".

projects/RabbitMQ.Client/client/api/InternalConstants.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,12 @@ internal static class InternalConstants
3737
{
3838
internal static readonly TimeSpan DefaultConnectionAbortTimeout = TimeSpan.FromSeconds(5);
3939
internal static readonly TimeSpan DefaultConnectionCloseTimeout = TimeSpan.FromSeconds(30);
40+
41+
/// <summary>
42+
/// Largest message size, in bytes, allowed in RabbitMQ.
43+
/// Note: <code>rabbit.max_message_size</code> setting (https://www.rabbitmq.com/configure.html)
44+
/// configures the largest message size which should be lower than this maximum of 128MiB.
45+
/// </summary>
46+
internal const uint DefaultRabbitMqMaxInboundMessageBodySize = 1_048_576 * 128;
4047
}
4148
}

projects/Test/Integration/TestConnectionFactory.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,9 @@ public async Task TestCreateConnectionUsesValidEndpointWhenMultipleSupplied()
339339
[Fact]
340340
public void TestCreateAmqpTCPEndPointOverridesMaxMessageSizeWhenGreaterThanMaximumAllowed()
341341
{
342-
_ = new AmqpTcpEndpoint("localhost", -1, new SslOption(),
343-
ConnectionFactory.DefaultRabbitMqMaxInboundMessageBodySize);
342+
var ep = new AmqpTcpEndpoint("localhost", -1, new SslOption(),
343+
2 * InternalConstants.DefaultRabbitMqMaxInboundMessageBodySize);
344+
Assert.Equal(InternalConstants.DefaultRabbitMqMaxInboundMessageBodySize, ep.MaxInboundMessageBodySize);
344345
}
345346

346347
[Fact]

0 commit comments

Comments
 (0)