Skip to content

Commit 4b3e1ff

Browse files
authored
Merge pull request #1381 from rabbitmq/update-comment-1378
Update API documentation of MaxMessageSize
2 parents 5d7741d + cb6657e commit 4b3e1ff

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ 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="maxMessageSize">Maximum message size from RabbitMQ. 0 means "unlimited"</param>
73+
/// <param name="maxMessageSize">Maximum message size from RabbitMQ. <see cref="ConnectionFactory.MaximumMaxMessageSize"/>. It defaults to
74+
/// MaximumMaxMessageSize if the parameter is greater than MaximumMaxMessageSize.</param>
7475
public AmqpTcpEndpoint(string hostName, int portOrMinusOne, SslOption ssl, uint maxMessageSize)
7576
{
7677
HostName = hostName;
7778
_port = portOrMinusOne;
7879
Ssl = ssl;
79-
_maxMessageSize = Math.Min(maxMessageSize, ConnectionFactory.DefaultMaxMessageSize);
80+
_maxMessageSize = Math.Min(maxMessageSize, ConnectionFactory.MaximumMaxMessageSize);
8081
}
8182

8283
/// <summary>
@@ -193,7 +194,8 @@ public IProtocol Protocol
193194
public SslOption Ssl { get; set; }
194195

195196
/// <summary>
196-
/// Get the maximum size for a message in bytes. The default value is 128MiB to match RabbitMQ's default
197+
/// Get the maximum size for a message in bytes.
198+
/// The default value is defined in <see cref="ConnectionFactory.DefaultMaxMessageSize"/>.
197199
/// </summary>
198200
public uint MaxMessageSize
199201
{

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,15 @@ public sealed class ConnectionFactory : ConnectionFactoryBase, IConnectionFactor
105105
public const uint DefaultFrameMax = 0;
106106

107107
/// <summary>
108-
/// Default value for the maximum allowed message size, in bytes, from RabbitMQ.
109-
/// Corresponds to the <code>rabbit.max_message_size</code> setting.
110-
/// Note: the default is 0 which means "unlimited".
108+
/// Default value for <code>ConnectionFactory</code>'s <code>MaxMessageSize</code>.
111109
/// </summary>
112-
public const uint DefaultMaxMessageSize = 536870912;
110+
public const uint DefaultMaxMessageSize = 134217728;
111+
/// <summary>
112+
/// Largest message size, in bytes, allowed in RabbitMQ.
113+
/// Note: <code>rabbit.max_message_size</code> setting (https://www.rabbitmq.com/configure.html)
114+
/// configures the largest message size which should be lower than this maximum of 536 Mbs.
115+
/// </summary>
116+
public const uint MaximumMaxMessageSize = 536870912;
113117

114118
/// <summary>
115119
/// Default value for desired heartbeat interval. Default is 60 seconds,
@@ -351,7 +355,7 @@ public AmqpTcpEndpoint Endpoint
351355

352356
/// <summary>
353357
/// Maximum allowed message size, in bytes, from RabbitMQ.
354-
/// Corresponds to the <code>rabbit.max_message_size</code> setting.
358+
/// Corresponds to the <code>ConnectionFactory.DefaultMaxMessageSize</code> setting.
355359
/// </summary>
356360
public uint MaxMessageSize { get; set; } = DefaultMaxMessageSize;
357361

projects/Unit/APIApproval.Approve.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,11 @@ namespace RabbitMQ.Client
165165
{
166166
public const ushort DefaultChannelMax = 2047;
167167
public const uint DefaultFrameMax = 0u;
168-
public const uint DefaultMaxMessageSize = 536870912u;
168+
public const uint DefaultMaxMessageSize = 134217728u;
169169
public const string DefaultPass = "guest";
170170
public const string DefaultUser = "guest";
171171
public const string DefaultVHost = "/";
172+
public const uint MaximumMaxMessageSize = 536870912u;
172173
public static readonly System.Collections.Generic.IList<RabbitMQ.Client.IAuthMechanismFactory> DefaultAuthMechanisms;
173174
public static readonly System.TimeSpan DefaultConnectionTimeout;
174175
public static readonly RabbitMQ.Client.ICredentialsRefresher DefaultCredentialsRefresher;

projects/Unit/TestConnectionFactory.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ public void TestCreateConnectioUsesValidEndpointWhenMultipleSupplied()
267267
using (IConnection conn = cf.CreateConnection(new List<AmqpTcpEndpoint> { invalidEp, ep })) { };
268268
}
269269

270+
[Fact]
271+
public void TestCreateAmqpTCPEndPointOverridesMaxMessageSizeWhenGreaterThanMaximumAllowed()
272+
{
273+
var ep = new AmqpTcpEndpoint("localhost", -1, new SslOption(), ConnectionFactory.MaximumMaxMessageSize);
274+
}
275+
270276
[Fact]
271277
public void TestCreateConnectionUsesConfiguredMaxMessageSize()
272278
{

0 commit comments

Comments
 (0)