@@ -56,19 +56,22 @@ public sealed class RabbitMQBinding : Binding
56
56
{
57
57
private String m_host ;
58
58
private int m_port ;
59
+ private long m_maxMessageSize ;
59
60
private IProtocol m_brokerProtocol ;
60
61
private CompositeDuplexBindingElement m_compositeDuplex ;
61
- private MessageEncodingBindingElement m_encoding ;
62
+ private TextMessageEncodingBindingElement m_encoding ;
62
63
private bool m_isInitialized ;
63
64
private bool m_oneWayOnly ;
64
65
private ReliableSessionBindingElement m_session ;
65
66
private TransactionFlowBindingElement m_transactionFlow ;
66
67
private bool m_transactionsEnabled ;
67
68
private RabbitMQTransportBindingElement m_transport ;
68
69
70
+ public static readonly long DefaultMaxMessageSize = 8192L ;
71
+
69
72
/// <summary>
70
- /// Creates a new instance of the RabbitMQBinding class initialized
71
- /// to use the Protocols.DefaultProtocol. The broker must be set
73
+ /// Creates a new instance of the RabbitMQBinding class initialized
74
+ /// to use the Protocols.DefaultProtocol. The broker must be set
72
75
/// before use.
73
76
/// </summary>
74
77
public RabbitMQBinding ( )
@@ -89,7 +92,7 @@ public RabbitMQBinding(String hostname, int port)
89
92
/// Uses the broker and protocol specified
90
93
/// </summary>
91
94
/// <param name="hostname">The hostname of the broker to connect to</param>
92
- /// <param name="port">The port of the broker to connect to</param>
95
+ /// <param name="port">The port of the broker to connect to</param>
93
96
/// <param name="protocol">The protocol version to use</param>
94
97
public RabbitMQBinding ( String hostname , int port , IProtocol protocol )
95
98
: this ( protocol )
@@ -98,6 +101,30 @@ public RabbitMQBinding(String hostname, int port, IProtocol protocol)
98
101
this . Port = port ;
99
102
}
100
103
104
+ /// <summary>
105
+ /// Uses the broker, login and protocol specified
106
+ /// </summary>
107
+ /// <param name="hostname">The hostname of the broker to connect to</param>
108
+ /// <param name="port">The port of the broker to connect to</param>
109
+ /// <param name="username">The broker username to connect with</param>
110
+ /// <param name="password">The broker password to connect with</param>
111
+ /// <param name="virtualhost">The broker virtual host</param>
112
+ /// <param name="maxMessageSize">The largest allowable encoded message size</param>
113
+ /// <param name="protocol">The protocol version to use</param>
114
+ public RabbitMQBinding ( String hostname , int port ,
115
+ String username , String password , String virtualhost ,
116
+ long maxMessageSize , IProtocol protocol )
117
+ : this ( protocol )
118
+ {
119
+ this . HostName = hostname ;
120
+ this . Port = port ;
121
+ this . Transport . Username = username ;
122
+ this . Transport . Password = password ;
123
+ this . Transport . VirtualHost = virtualhost ;
124
+ this . MaxMessageSize = maxMessageSize ;
125
+
126
+ }
127
+
101
128
/// <summary>
102
129
/// Uses the specified protocol. The broker must be set before use.
103
130
/// </summary>
@@ -118,6 +145,10 @@ public override BindingElementCollection CreateBindingElements()
118
145
m_transport . HostName = this . HostName ;
119
146
m_transport . Port = this . Port ;
120
147
m_transport . BrokerProtocol = this . BrokerProtocol ;
148
+ if ( MaxMessageSize != DefaultMaxMessageSize )
149
+ {
150
+ m_transport . MaxReceivedMessageSize = MaxMessageSize ;
151
+ }
121
152
BindingElementCollection elements = new BindingElementCollection ( ) ;
122
153
123
154
if ( m_transactionsEnabled )
@@ -146,12 +177,12 @@ private void Initialize()
146
177
m_session = new ReliableSessionBindingElement ( ) ;
147
178
m_compositeDuplex = new CompositeDuplexBindingElement ( ) ;
148
179
m_transactionFlow = new TransactionFlowBindingElement ( ) ;
149
-
180
+ m_maxMessageSize = DefaultMaxMessageSize ;
150
181
m_isInitialized = true ;
151
182
}
152
183
}
153
184
}
154
-
185
+
155
186
/// <summary>
156
187
/// Gets the scheme used by the binding, soap.amqp
157
188
/// </summary>
@@ -180,6 +211,16 @@ public int Port
180
211
set { m_port = value ; }
181
212
}
182
213
214
+ /// <summary>
215
+ /// Specifies the maximum encoded message size
216
+ /// </summary>
217
+ [ ConfigurationProperty ( "maxmessagesize" ) ]
218
+ public long MaxMessageSize
219
+ {
220
+ get { return m_maxMessageSize ; }
221
+ set { m_maxMessageSize = value ; }
222
+ }
223
+
183
224
/// <summary>
184
225
/// Specifies the version of the AMQP protocol that should be used to communicate with the broker
185
226
/// </summary>
@@ -206,7 +247,7 @@ public ReliableSession ReliableSession
206
247
}
207
248
208
249
/// <summary>
209
- /// Determines whether or not the TransactionFlowBindingElement will
250
+ /// Determines whether or not the TransactionFlowBindingElement will
210
251
/// be added to the channel stack
211
252
/// </summary>
212
253
public bool TransactionFlow
0 commit comments