Skip to content

RabbitMQ client-side MaxInboundMessageBodySize not configurable via appsettings.json #25833

Description

@a-herbst

Is there an existing issue for this?

  • I have searched the existing issues

Description

Since rabbitmq-client-dotnet 7.x the C# RabbitMQ client enforces a max message body size for incoming messages through the ConnectionFactory.MaxInboundMessageBodySize property. This is set to 64 MB per default.

See RabbitMQ-PR rabbitmq/rabbitmq-dotnet-client#1566

According to

Configure<AbpRabbitMqOptions>(configuration.GetSection("RabbitMQ"));

... this property should be configurable through appsettings.json by setting the RabbitMQ:Connections:Default:MaxInboundMessageBodySize value:

{
  "RabbitMQ": {
    "Connections": {
      "Default": {
        "HostName": "123.123.123.123"
        "Port": "5672",

        "MaxInboundMessageBodySize": "500000000"
      }
    }
  }
}

But when the ConnectionPool fetches the ConnectionFactory from dependency injection it contains the configured values for "HostName" and "Port" but still uses the default value for "MaxInboundMessageBodySize" of 67108864 (64 MB).

var connectionFactory = Options.Connections.GetOrDefault(connectionName);

Reproduction Steps

Create or reusae any abp project that uses the Volo.Abp.EventBus.RabbitMq module:

  • set the MaxInboundMessageBodySize property for the RabbitMq connection in
    appsettings.json
    {
      "RabbitMQ": {
        "Connections": {
          "Default": {
            "HostName": "123.123.123.123"
            "Port": "5672",
    
           "MaxInboundMessageBodySize": "500000000"
          }
        }
      },
      ...
    }
  • Set a breakpoint in ConnectionPool.GetAsync() -
    var connectionFactory = Options.Connections.GetOrDefault(connectionName);
  • Start the application

Expected behavior

-> When the breakpoint halts the connectionFactory object fetched from dependency injection should be configured with
MaxInboundMessageBodySize: 500000000

Actual behavior

-> When the breakpoint halts the connectionFactory object fetched from dependency injection is configured with

  • ✅ HostName: "123.123.123.123"
  • ✅ Port: 5672
  • ❌ MaxInboundMessageBodySize: 67108864

Regression?

No response

Known Workarounds

Pass the configuration value RabbitMQ:Connections:Default:MaxInboundMessageBodySize into the AbpRabbitMqOptions object per code "manually":

        Configure<AbpRabbitMqOptions>(options =>
        {
            var rabbitMqConnectionsSection = configuration.GetSection("RabbitMQ:Connections");

            foreach (var connectionSection in rabbitMqConnectionsSection.GetChildren())
            {
                options.Connections[connectionSection.Key].MaxInboundMessageBodySize = connectionSection.GetValue<uint>(
                    "MaxInboundMessageBodySize",
                    ConnectionFactory.DefaultMaxInboundMessageBodySize
                );
            }
        });

Version

10.4.1

User Interface

Common (Default)

Database Provider

EF Core (Default)

Tiered or separate authentication server

None (Default)

Operation System

Windows (Default)

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions