Skip to content

Commit f715f26

Browse files
author
Simon MacMullen
committed
Merge bug24134 into default
2 parents 80810f1 + 2afdfe5 commit f715f26

9 files changed

+87
-12
lines changed

docs/RabbitMQ Service Model.doc

6 KB
Binary file not shown.

docs/RabbitMQ Service Model.docx

5.68 KB
Binary file not shown.

docs/RabbitMQ Service Model.pdf

174 KB
Binary file not shown.

projects/wcf/RabbitMQ.ServiceModel/RabbitMQ.ServiceModel.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<Reference Include="System.Data" />
8484
<Reference Include="System.ServiceModel"><RequiredTargetFramework>3.0</RequiredTargetFramework></Reference>
8585
<Reference Include="System.Xml" />
86+
<Reference Include="System.Runtime.Serialization" />
8687
</ItemGroup>
8788
<ItemGroup>
8889
<ProjectReference Include="..\..\client\RabbitMQ.Client\RabbitMQ.Client.csproj">

projects/wcf/RabbitMQ.ServiceModel/src/serviceModel/RabbitMQBinding.cs

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,22 @@ public sealed class RabbitMQBinding : Binding
5656
{
5757
private String m_host;
5858
private int m_port;
59+
private long m_maxMessageSize;
5960
private IProtocol m_brokerProtocol;
6061
private CompositeDuplexBindingElement m_compositeDuplex;
61-
private MessageEncodingBindingElement m_encoding;
62+
private TextMessageEncodingBindingElement m_encoding;
6263
private bool m_isInitialized;
6364
private bool m_oneWayOnly;
6465
private ReliableSessionBindingElement m_session;
6566
private TransactionFlowBindingElement m_transactionFlow;
6667
private bool m_transactionsEnabled;
6768
private RabbitMQTransportBindingElement m_transport;
6869

70+
public static readonly long DefaultMaxMessageSize = 8192L;
71+
6972
/// <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
7275
/// before use.
7376
/// </summary>
7477
public RabbitMQBinding()
@@ -89,7 +92,7 @@ public RabbitMQBinding(String hostname, int port)
8992
/// Uses the broker and protocol specified
9093
/// </summary>
9194
/// <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>
9396
/// <param name="protocol">The protocol version to use</param>
9497
public RabbitMQBinding(String hostname, int port, IProtocol protocol)
9598
: this(protocol)
@@ -98,6 +101,30 @@ public RabbitMQBinding(String hostname, int port, IProtocol protocol)
98101
this.Port = port;
99102
}
100103

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+
101128
/// <summary>
102129
/// Uses the specified protocol. The broker must be set before use.
103130
/// </summary>
@@ -118,6 +145,10 @@ public override BindingElementCollection CreateBindingElements()
118145
m_transport.HostName = this.HostName;
119146
m_transport.Port = this.Port;
120147
m_transport.BrokerProtocol = this.BrokerProtocol;
148+
if (MaxMessageSize != DefaultMaxMessageSize)
149+
{
150+
m_transport.MaxReceivedMessageSize = MaxMessageSize;
151+
}
121152
BindingElementCollection elements = new BindingElementCollection();
122153

123154
if (m_transactionsEnabled)
@@ -146,12 +177,12 @@ private void Initialize()
146177
m_session = new ReliableSessionBindingElement();
147178
m_compositeDuplex = new CompositeDuplexBindingElement();
148179
m_transactionFlow = new TransactionFlowBindingElement();
149-
180+
m_maxMessageSize = DefaultMaxMessageSize;
150181
m_isInitialized = true;
151182
}
152183
}
153184
}
154-
185+
155186
/// <summary>
156187
/// Gets the scheme used by the binding, soap.amqp
157188
/// </summary>
@@ -180,6 +211,16 @@ public int Port
180211
set { m_port = value; }
181212
}
182213

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+
183224
/// <summary>
184225
/// Specifies the version of the AMQP protocol that should be used to communicate with the broker
185226
/// </summary>
@@ -206,7 +247,7 @@ public ReliableSession ReliableSession
206247
}
207248

208249
/// <summary>
209-
/// Determines whether or not the TransactionFlowBindingElement will
250+
/// Determines whether or not the TransactionFlowBindingElement will
210251
/// be added to the channel stack
211252
/// </summary>
212253
public bool TransactionFlow

projects/wcf/RabbitMQ.ServiceModel/src/serviceModel/RabbitMQBindingConfigurationElement.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ protected override void InitializeFrom(Binding binding)
8383
{
8484
this.HostName = rabbind.HostName;
8585
this.Port = rabbind.Port;
86+
this.MaxMessageSize = rabbind.MaxMessageSize;
8687
this.OneWayOnly = rabbind.OneWayOnly;
8788
this.TransactionFlowEnabled = rabbind.TransactionFlow;
8889
this.VirtualHost = rabbind.Transport.ConnectionFactory.VirtualHost;
@@ -110,9 +111,10 @@ protected override void OnApplyConfiguration(Binding binding)
110111
rabbind.BrokerProtocol = this.Protocol;
111112
rabbind.OneWayOnly = this.OneWayOnly;
112113
rabbind.TransactionFlow = this.TransactionFlowEnabled;
113-
rabbind.Transport.ConnectionFactory.Password = this.Password;
114-
rabbind.Transport.ConnectionFactory.UserName = this.Username;
115-
rabbind.Transport.ConnectionFactory.VirtualHost = this.VirtualHost;
114+
rabbind.Transport.Password = this.Password;
115+
rabbind.Transport.Username = this.Username;
116+
rabbind.Transport.VirtualHost = this.VirtualHost;
117+
rabbind.Transport.MaxReceivedMessageSize = this.MaxMessageSize;
116118
}
117119

118120
/// <summary>
@@ -191,6 +193,16 @@ public string ProtocolVersion
191193
}
192194
}
193195

196+
/// <summary>
197+
/// Specifies the maximum encoded message size
198+
/// </summary>
199+
[ConfigurationProperty("maxmessagesize", DefaultValue = 8192L)]
200+
public long MaxMessageSize
201+
{
202+
get { return (long)base["maxmessagesize"]; }
203+
set { base["maxmessagesize"] = value; }
204+
}
205+
194206
private IProtocol GetProtocol() {
195207
IProtocol result = Protocols.Lookup(this.ProtocolVersion);
196208
if (result == null) {

projects/wcf/RabbitMQ.ServiceModel/src/serviceModel/RabbitMQInputChannel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public RabbitMQInputChannel(BindingContext context, IModel model, EndpointAddres
6767
: base(context, address)
6868
{
6969
m_bindingElement = context.Binding.Elements.Find<RabbitMQTransportBindingElement>();
70-
MessageEncodingBindingElement encoderElem = context.BindingParameters.Find<MessageEncodingBindingElement>();
70+
TextMessageEncodingBindingElement encoderElem = context.BindingParameters.Find<TextMessageEncodingBindingElement>();
71+
encoderElem.ReaderQuotas.MaxStringContentLength = (int)m_bindingElement.MaxReceivedMessageSize;
7172
if (encoderElem != null) {
7273
m_encoder = encoderElem.CreateMessageEncoderFactory().Encoder;
7374
}

projects/wcf/RabbitMQ.ServiceModel/src/serviceModel/RabbitMQTransportBindingElement.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public sealed class RabbitMQTransportBindingElement : TransportBindingElement
6060
private IProtocol m_protocol;
6161
private String m_host;
6262
private int m_port;
63+
private long m_maxReceivedMessageSize;
6364
private String m_username;
6465
private String m_password;
6566
private String m_vhost;
@@ -69,17 +70,18 @@ public sealed class RabbitMQTransportBindingElement : TransportBindingElement
6970
/// </summary>
7071
public RabbitMQTransportBindingElement()
7172
{
73+
MaxReceivedMessageSize = RabbitMQBinding.DefaultMaxMessageSize;
7274
}
7375

7476
private RabbitMQTransportBindingElement(RabbitMQTransportBindingElement other)
75-
: this()
7677
{
7778
HostName = other.HostName;
7879
Port = other.Port;
7980
BrokerProtocol = other.BrokerProtocol;
8081
Username = other.Username;
8182
Password = other.Password;
8283
VirtualHost = other.VirtualHost;
84+
MaxReceivedMessageSize = other.MaxReceivedMessageSize;
8385
}
8486

8587

@@ -190,6 +192,15 @@ public int Port
190192
}
191193
}
192194

195+
/// <summary>
196+
/// The largest receivable encoded message
197+
/// </summary>
198+
public override long MaxReceivedMessageSize
199+
{
200+
get { return m_maxReceivedMessageSize; }
201+
set { m_maxReceivedMessageSize = value; }
202+
}
203+
193204
/// <summary>
194205
/// The username to use when authenticating with the broker
195206
/// </summary>

projects/wcf/RabbitMQ.ServiceModel/src/serviceModel/RabbitMQTransportElement.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ public string VirtualHost
212212
set { base["virtualHost"] = value; }
213213
}
214214

215+
/// <summary>
216+
/// The largest receivable encoded message
217+
/// </summary>
218+
public new long MaxReceivedMessageSize
219+
{
220+
get { return MaxReceivedMessageSize; }
221+
set { MaxReceivedMessageSize = value; }
222+
}
223+
215224
protected override ConfigurationPropertyCollection Properties
216225
{
217226
get

0 commit comments

Comments
 (0)