diff --git a/ChangeLog.md b/ChangeLog.md index 2ab2b27..d3d6e1e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,9 @@ +## Changes Between 4.6.0 and 4.7.0 (under development) + +### Support for setting maximum inbound message size + +Add configuration option to set the `maxInboundMessageBodySize` on the ConnectionFactory + ## Changes Between 4.5.0 and 4.6.0 (Nov 10, 2023) ### RabbitMQ Java Client Upgrade diff --git a/lib/march_hare/session.rb b/lib/march_hare/session.rb index 6c24691..932bf13 100644 --- a/lib/march_hare/session.rb +++ b/lib/march_hare/session.rb @@ -57,6 +57,7 @@ class Session # @option options [Logger] :logger The logger. If missing, one is created using :log_file and :log_level. # @option options [IO, String] :log_file The file or path to use when creating a logger. Defaults to STDOUT. # @option options [Integer] :log_level The log level to use when creating a logger. Defaults to LOGGER::WARN + # @option options [Integer] :max_inbound_message_body_size Maximum allowed size of an incoming message body. Defaults to 64MiB # # @see http://rubymarchhare.info/articles/connecting.html Connecting to RabbitMQ guide def self.connect(options = {}) @@ -83,6 +84,8 @@ def self.connect(options = {}) cf.thread_factory = thread_factory_from(options) if include_thread_factory?(options) + cf.max_inbound_message_body_size = options[:max_inbound_message_body_size].to_i if options[:max_inbound_message_body_size] + tls = (options[:ssl] || options[:tls]) case tls when true then diff --git a/spec/higher_level_api/integration/connection_spec.rb b/spec/higher_level_api/integration/connection_spec.rb index 7c277cc..68d1226 100644 --- a/spec/higher_level_api/integration/connection_spec.rb +++ b/spec/higher_level_api/integration/connection_spec.rb @@ -135,6 +135,13 @@ def newThread(runnable) c.close end + it "lets you specify a maximum inbound message size" do + c = MarchHare.connect(max_inbound_message_body_size: 64000) + expect(c).to be_connected + c.close + end + + it "lets you specify exception handler" do class ExceptionHandler < com.rabbitmq.client.impl.DefaultExceptionHandler include com.rabbitmq.client.ExceptionHandler