Skip to content

Commit

Permalink
GH-2495: Add maxInboundMessageBodySize to RCFB
Browse files Browse the repository at this point in the history
Resolves #2495

Although the factory bean has...

```java
	/**
	 * Access the connection factory to set any other properties not supported by
	 * this factory bean.
	 * @return the connection factory.
	 * @SInCE 1.7.14
	 */
	public ConnectionFactory getRabbitConnectionFactory() {
```

...this new CF property could be a breaking change for users that configure the
factory bean using XML.

**cherry-pick to 2.4.x**

(cherry picked from commit a18470d)
  • Loading branch information
garyrussell authored and artembilan committed Jul 26, 2023
1 parent a9a6892 commit c00f588
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,7 +66,7 @@
* using the supplied properties and intializes key and trust manager factories, using
* algorithm {@code SunX509} by default. These are then used to initialize an
* {@link SSLContext} using the {@link #setSslAlgorithm(String) sslAlgorithm} (default
* TLSv1.1).
* TLSv1.2, falling back to TLSv1.1, if 1.2 is not available).
* <p>
* Override {@link #createSSLContext()} to create and/or perform further modification of
* the context.
Expand Down Expand Up @@ -672,6 +672,16 @@ public void setEnableHostnameVerification(boolean enable) {
this.enableHostnameVerification = enable;
}

/**
* Set the maximum body size of inbound (received) messages in bytes.
* @param maxInboundMessageBodySize the maximum size.
* @since 2.4.15
* @see com.rabbitmq.client.ConnectionFactory#setMaxInboundMessageBodySize(int)
*/
public void setMaxInboundMessageBodySize(int maxInboundMessageBodySize) {
this.connectionFactory.setMaxInboundMessageBodySize(maxInboundMessageBodySize);
}

protected String getKeyStoreAlgorithm() {
return this.keyStoreAlgorithm;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -76,13 +76,15 @@ public void test() throws Exception {
@Test
public void testAlgNoProps() throws Exception {
RabbitConnectionFactoryBean fb = new RabbitConnectionFactoryBean();
fb.setMaxInboundMessageBodySize(1000);
ConnectionFactory rabbitCf = spy(TestUtils.getPropertyValue(fb, "connectionFactory", ConnectionFactory.class));
new DirectFieldAccessor(fb).setPropertyValue("connectionFactory", rabbitCf);
fb.setUseSSL(true);
fb.setSslAlgorithm("TLSv1.2");
fb.afterPropertiesSet();
fb.getObject();
verify(rabbitCf).useSslProtocol(Mockito.any(SSLContext.class));
assertThat(rabbitCf).hasFieldOrPropertyWithValue("maxInboundMessageBodySize", 1000);
}

@Test
Expand Down

0 comments on commit c00f588

Please # to comment.