From 128aca50ed20b789ef512695975b2609abc46db2 Mon Sep 17 00:00:00 2001 From: okubis Date: Tue, 30 Apr 2024 13:49:16 +0200 Subject: [PATCH] Add configuration for max inbound message size (#212) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add configuration for max inbound message size; set default to 512MB --------- Co-authored-by: Daniel Slunečko --- .../com/avast/clients/rabbitmq/RabbitMQConnection.scala | 1 + .../scala/com/avast/clients/rabbitmq/configuration.scala | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/scala/com/avast/clients/rabbitmq/RabbitMQConnection.scala b/core/src/main/scala/com/avast/clients/rabbitmq/RabbitMQConnection.scala index f4baaefa..ed036b3a 100644 --- a/core/src/main/scala/com/avast/clients/rabbitmq/RabbitMQConnection.scala +++ b/core/src/main/scala/com/avast/clients/rabbitmq/RabbitMQConnection.scala @@ -216,6 +216,7 @@ object RabbitMQConnection { } factory.setConnectionTimeout(connectionTimeout.toMillis.toInt) + factory.setMaxInboundMessageBodySize(connectionConfig.maxInboundMessageBodySize) } // scalastyle:off diff --git a/core/src/main/scala/com/avast/clients/rabbitmq/configuration.scala b/core/src/main/scala/com/avast/clients/rabbitmq/configuration.scala index 3f955198..52987c75 100644 --- a/core/src/main/scala/com/avast/clients/rabbitmq/configuration.scala +++ b/core/src/main/scala/com/avast/clients/rabbitmq/configuration.scala @@ -19,7 +19,10 @@ final case class RabbitMQConnectionConfig(name: String, networkRecovery: NetworkRecoveryConfig = NetworkRecoveryConfig(), channelMax: Int = 2047, credentials: CredentialsConfig, - republishStrategy: RepublishStrategyConfig = RepublishStrategyConfig.DefaultExchange) + republishStrategy: RepublishStrategyConfig = RepublishStrategyConfig.DefaultExchange, + // This is the new hard-limit on server side. see: + // https://github.com/rabbitmq/rabbitmq-common/blob/67c4397ffa9f51d87f994aa4db4a68e8e95326ab/include/rabbit.hrl#L250 + maxInboundMessageBodySize: Int = 536870912) final case class NetworkRecoveryConfig(enabled: Boolean = true, handler: RecoveryDelayHandler = RecoveryDelayHandlers.Linear())