@@ -15,6 +15,7 @@ public class ConnectionSettingBuilder
1515 private string _scheme = "AMQP" ;
1616 private string _connectionName = "AMQP.NET" ;
1717 private string _virtualHost = "/" ;
18+ private uint _maxFrameSize = Consts . DefaultMaxFrameSize ;
1819 private SaslMechanism _saslMechanism = Client . SaslMechanism . Plain ;
1920 private IRecoveryConfiguration _recoveryConfiguration = Impl . RecoveryConfiguration . Create ( ) ;
2021
@@ -69,6 +70,17 @@ public ConnectionSettingBuilder VirtualHost(string virtualHost)
6970 return this ;
7071 }
7172
73+ public ConnectionSettingBuilder MaxFrameSize ( uint maxFrameSize )
74+ {
75+ _maxFrameSize = maxFrameSize ;
76+ if ( _maxFrameSize != uint . MinValue && _maxFrameSize < 512 )
77+ {
78+ throw new ArgumentOutOfRangeException ( nameof ( maxFrameSize ) ,
79+ "maxFrameSize must be greater or equal to 512" ) ;
80+ }
81+ return this ;
82+ }
83+
7284 public ConnectionSettingBuilder SaslMechanism ( SaslMechanism saslMechanism )
7385 {
7486 _saslMechanism = saslMechanism ;
@@ -89,9 +101,9 @@ public ConnectionSettingBuilder RecoveryConfiguration(IRecoveryConfiguration rec
89101
90102 public ConnectionSettings Build ( )
91103 {
92- var c = new ConnectionSettings ( _host , _port , _user ,
104+ var c = new ConnectionSettings ( _scheme , _host , _port , _user ,
93105 _password , _virtualHost ,
94- _scheme , _connectionName , _saslMechanism )
106+ _connectionName , _saslMechanism , _maxFrameSize )
95107 {
96108 Recovery = ( RecoveryConfiguration ) _recoveryConfiguration
97109 } ;
@@ -106,8 +118,9 @@ public ConnectionSettings Build()
106118public class ConnectionSettings : IConnectionSettings
107119{
108120 private readonly Address _address ;
109- private readonly string _connectionName = "" ;
110121 private readonly string _virtualHost = "/" ;
122+ private readonly string _connectionName = "" ;
123+ private readonly uint _maxFrameSize = Consts . DefaultMaxFrameSize ;
111124 private readonly ITlsSettings ? _tlsSettings ;
112125 private readonly SaslMechanism _saslMechanism = SaslMechanism . Plain ;
113126
@@ -122,17 +135,27 @@ public ConnectionSettings(string address, ITlsSettings? tlsSettings = null)
122135 }
123136 }
124137
125- public ConnectionSettings ( string host , int port ,
138+ public ConnectionSettings ( string scheme , string host , int port ,
126139 string ? user , string ? password ,
127- string virtualHost , string scheme , string connectionName ,
128- SaslMechanism saslMechanism , ITlsSettings ? tlsSettings = null )
140+ string virtualHost , string connectionName ,
141+ SaslMechanism saslMechanism ,
142+ uint maxFrameSize = Consts . DefaultMaxFrameSize ,
143+ ITlsSettings ? tlsSettings = null )
129144 {
130145 _address = new Address ( host : host , port : port ,
131146 user : user , password : password ,
132147 path : "/" , scheme : scheme ) ;
133148 _connectionName = connectionName ;
134149 _virtualHost = virtualHost ;
135150 _saslMechanism = saslMechanism ;
151+
152+ _maxFrameSize = maxFrameSize ;
153+ if ( _maxFrameSize != uint . MinValue && _maxFrameSize < 512 )
154+ {
155+ throw new ArgumentOutOfRangeException ( nameof ( maxFrameSize ) ,
156+ "maxFrameSize must be greater or equal to 512" ) ;
157+ }
158+
136159 _tlsSettings = tlsSettings ;
137160
138161 if ( _address . UseSsl && _tlsSettings == null )
@@ -150,8 +173,8 @@ public ConnectionSettings(string host, int port,
150173 public string ConnectionName => _connectionName ;
151174 public string Path => _address . Path ;
152175 public bool UseSsl => _address . UseSsl ;
176+ public uint MaxFrameSize => _maxFrameSize ;
153177 public SaslMechanism SaslMechanism => _saslMechanism ;
154-
155178 public ITlsSettings ? TlsSettings => _tlsSettings ;
156179 public IRecoveryConfiguration Recovery { get ; init ; } = RecoveryConfiguration . Create ( ) ;
157180
0 commit comments