From 84a7fb3e33ae64a821c2020fd909055e3032a15a Mon Sep 17 00:00:00 2001 From: malakaganga Date: Tue, 10 Dec 2024 15:25:34 +0530 Subject: [PATCH] Add RabbitMq maxInboundMessageBodySize Fixes: https://github.com/wso2/product-micro-integrator/issues/3801 --- .../axis2/transport/rabbitmq/RabbitMQConnectionFactory.java | 5 +++++ .../apache/axis2/transport/rabbitmq/RabbitMQConstants.java | 1 + 2 files changed, 6 insertions(+) diff --git a/modules/rabbitmq/src/main/java/org/apache/axis2/transport/rabbitmq/RabbitMQConnectionFactory.java b/modules/rabbitmq/src/main/java/org/apache/axis2/transport/rabbitmq/RabbitMQConnectionFactory.java index eaddc181..621b505b 100644 --- a/modules/rabbitmq/src/main/java/org/apache/axis2/transport/rabbitmq/RabbitMQConnectionFactory.java +++ b/modules/rabbitmq/src/main/java/org/apache/axis2/transport/rabbitmq/RabbitMQConnectionFactory.java @@ -214,6 +214,7 @@ private ConnectionFactory loadConnectionFactory(Map parameters) BooleanUtils.toBoolean(parameters.get(RabbitMQConstants.SSL_ENABLED)), false); boolean externalAuthEnabled = BooleanUtils.toBooleanDefaultIfNull( BooleanUtils.toBoolean(parameters.get(RabbitMQConstants.EXTERNAL_AUTH_MECHANISM)), false); + String maxInboundMessageSize = parameters.get(RabbitMQConstants.MAX_INBOUND_MESSAGE_BODY_SIZE); String[] hostnameArray = hostnames.split(","); String[] portArray = ports.split(","); @@ -239,6 +240,10 @@ private ConnectionFactory loadConnectionFactory(Map parameters) connectionFactory.setNetworkRecoveryInterval(networkRecoveryInterval); connectionFactory.setAutomaticRecoveryEnabled(true); connectionFactory.setTopologyRecoveryEnabled(true); + if (StringUtils.isNotEmpty(maxInboundMessageSize)) { + int maxInboundMessageSizeInt = NumberUtils.toInt(maxInboundMessageSize); + connectionFactory.setMaxInboundMessageBodySize(maxInboundMessageSizeInt); + } if (externalAuthEnabled) { connectionFactory.setSaslConfig(DefaultSaslConfig.EXTERNAL); } diff --git a/modules/rabbitmq/src/main/java/org/apache/axis2/transport/rabbitmq/RabbitMQConstants.java b/modules/rabbitmq/src/main/java/org/apache/axis2/transport/rabbitmq/RabbitMQConstants.java index 0bc5e4a1..56e64931 100644 --- a/modules/rabbitmq/src/main/java/org/apache/axis2/transport/rabbitmq/RabbitMQConstants.java +++ b/modules/rabbitmq/src/main/java/org/apache/axis2/transport/rabbitmq/RabbitMQConstants.java @@ -45,6 +45,7 @@ public class RabbitMQConstants { public static final String NETWORK_RECOVERY_INTERVAL = "rabbitmq.connection.factory.network.recovery.interval"; public static final String RETRY_INTERVAL = "rabbitmq.connection.retry.interval"; public static final String RETRY_COUNT = "rabbitmq.connection.retry.count"; + public static final String MAX_INBOUND_MESSAGE_BODY_SIZE = "rabbitmq.max.inbound.message.body.size"; public static final String CORRELATION_ID = "rabbitmq.message.correlation.id"; public static final String MESSAGE_ID = "rabbitmq.message.id";