Skip to content

Commit

Permalink
Merge pull request #1381 from rabbitmq/update-comment-1378
Browse files Browse the repository at this point in the history
Update API documentation of MaxMessageSize
  • Loading branch information
lukebakken authored Oct 13, 2023
2 parents 5d7741d + cb6657e commit 4b3e1ff
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
8 changes: 5 additions & 3 deletions projects/RabbitMQ.Client/client/api/AmqpTcpEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ 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="maxMessageSize">Maximum message size from RabbitMQ. 0 means "unlimited"</param>
/// <param name="maxMessageSize">Maximum message size from RabbitMQ. <see cref="ConnectionFactory.MaximumMaxMessageSize"/>. It defaults to
/// MaximumMaxMessageSize if the parameter is greater than MaximumMaxMessageSize.</param>
public AmqpTcpEndpoint(string hostName, int portOrMinusOne, SslOption ssl, uint maxMessageSize)
{
HostName = hostName;
_port = portOrMinusOne;
Ssl = ssl;
_maxMessageSize = Math.Min(maxMessageSize, ConnectionFactory.DefaultMaxMessageSize);
_maxMessageSize = Math.Min(maxMessageSize, ConnectionFactory.MaximumMaxMessageSize);
}

/// <summary>
Expand Down Expand Up @@ -193,7 +194,8 @@ public IProtocol Protocol
public SslOption Ssl { get; set; }

/// <summary>
/// Get the maximum size for a message in bytes. The default value is 128MiB to match RabbitMQ's default
/// Get the maximum size for a message in bytes.
/// The default value is defined in <see cref="ConnectionFactory.DefaultMaxMessageSize"/>.
/// </summary>
public uint MaxMessageSize
{
Expand Down
14 changes: 9 additions & 5 deletions projects/RabbitMQ.Client/client/api/ConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,15 @@ public sealed class ConnectionFactory : ConnectionFactoryBase, IConnectionFactor
public const uint DefaultFrameMax = 0;

/// <summary>
/// Default value for the maximum allowed message size, in bytes, from RabbitMQ.
/// Corresponds to the <code>rabbit.max_message_size</code> setting.
/// Note: the default is 0 which means "unlimited".
/// Default value for <code>ConnectionFactory</code>'s <code>MaxMessageSize</code>.
/// </summary>
public const uint DefaultMaxMessageSize = 536870912;
public const uint DefaultMaxMessageSize = 134217728;
/// <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 536 Mbs.
/// </summary>
public const uint MaximumMaxMessageSize = 536870912;

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

/// <summary>
/// Maximum allowed message size, in bytes, from RabbitMQ.
/// Corresponds to the <code>rabbit.max_message_size</code> setting.
/// Corresponds to the <code>ConnectionFactory.DefaultMaxMessageSize</code> setting.
/// </summary>
public uint MaxMessageSize { get; set; } = DefaultMaxMessageSize;

Expand Down
3 changes: 2 additions & 1 deletion projects/Unit/APIApproval.Approve.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,11 @@ namespace RabbitMQ.Client
{
public const ushort DefaultChannelMax = 2047;
public const uint DefaultFrameMax = 0u;
public const uint DefaultMaxMessageSize = 536870912u;
public const uint DefaultMaxMessageSize = 134217728u;
public const string DefaultPass = "guest";
public const string DefaultUser = "guest";
public const string DefaultVHost = "/";
public const uint MaximumMaxMessageSize = 536870912u;
public static readonly System.Collections.Generic.IList<RabbitMQ.Client.IAuthMechanismFactory> DefaultAuthMechanisms;
public static readonly System.TimeSpan DefaultConnectionTimeout;
public static readonly RabbitMQ.Client.ICredentialsRefresher DefaultCredentialsRefresher;
Expand Down
6 changes: 6 additions & 0 deletions projects/Unit/TestConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ public void TestCreateConnectioUsesValidEndpointWhenMultipleSupplied()
using (IConnection conn = cf.CreateConnection(new List<AmqpTcpEndpoint> { invalidEp, ep })) { };
}

[Fact]
public void TestCreateAmqpTCPEndPointOverridesMaxMessageSizeWhenGreaterThanMaximumAllowed()
{
var ep = new AmqpTcpEndpoint("localhost", -1, new SslOption(), ConnectionFactory.MaximumMaxMessageSize);
}

[Fact]
public void TestCreateConnectionUsesConfiguredMaxMessageSize()
{
Expand Down

0 comments on commit 4b3e1ff

Please sign in to comment.