Skip to content

Commit 8e1a4ea

Browse files
author
Emile Joubert
committed
Merged bug24036 into bug24131
2 parents 8571076 + 00a6aab commit 8e1a4ea

9 files changed

+64
-11
lines changed

docs/RabbitMQ Service Model.doc

5 KB
Binary file not shown.

docs/RabbitMQ Service Model.docx

1.04 KB
Binary file not shown.

docs/RabbitMQ Service Model.pdf

70.3 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: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ 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;
@@ -67,8 +68,8 @@ public sealed class RabbitMQBinding : Binding
6768
private RabbitMQTransportBindingElement m_transport;
6869

6970
/// <summary>
70-
/// Creates a new instance of the RabbitMQBinding class initialized
71-
/// to use the Protocols.DefaultProtocol. The broker must be set
71+
/// Creates a new instance of the RabbitMQBinding class initialized
72+
/// to use the Protocols.DefaultProtocol. The broker must be set
7273
/// before use.
7374
/// </summary>
7475
public RabbitMQBinding()
@@ -79,7 +80,8 @@ public RabbitMQBinding()
7980
/// Uses the default protocol and the broker specified by the given
8081
/// Uri.
8182
/// </summary>
82-
/// <param name="broker">The address of the broker to connect to</param>
83+
/// <param name="hostname">The hostname of the broker to connect to</param>
84+
/// <param name="port">The port of the broker to connect to</param>
8385
public RabbitMQBinding(String hostname, int port)
8486
: this(hostname, port, Protocols.DefaultProtocol)
8587
{ }
@@ -88,7 +90,7 @@ public RabbitMQBinding(String hostname, int port)
8890
/// Uses the broker and protocol specified
8991
/// </summary>
9092
/// <param name="hostname">The hostname of the broker to connect to</param>
91-
/// <param name="port">The port of the broker to connect to</param>
93+
/// <param name="port">The port of the broker to connect to</param>
9294
/// <param name="protocol">The protocol version to use</param>
9395
public RabbitMQBinding(String hostname, int port, IProtocol protocol)
9496
: this(protocol)
@@ -104,15 +106,21 @@ public RabbitMQBinding(String hostname, int port, IProtocol protocol)
104106
/// <param name="port">The port of the broker to connect to</param>
105107
/// <param name="username">The broker username to connect with</param>
106108
/// <param name="password">The broker password to connect with</param>
109+
/// <param name="virtualhost">The broker virtual host</param>
110+
/// <param name="maxMessageSize">The largest allowable encoded message size</param>
107111
/// <param name="protocol">The protocol version to use</param>
108-
public RabbitMQBinding(String hostname, int port,
109-
String username, String password, IProtocol protocol)
112+
public RabbitMQBinding(String hostname, int port,
113+
String username, String password, String virtualhost,
114+
long maxMessageSize, IProtocol protocol)
110115
: this(protocol)
111116
{
112117
this.HostName = hostname;
113118
this.Port = port;
114119
this.Transport.Username = username;
115120
this.Transport.Password = password;
121+
this.Transport.VirtualHost;
122+
this.MaxMessageSize = maxMessageSize;
123+
116124
}
117125

118126
/// <summary>
@@ -135,6 +143,7 @@ public override BindingElementCollection CreateBindingElements()
135143
m_transport.HostName = this.HostName;
136144
m_transport.Port = this.Port;
137145
m_transport.BrokerProtocol = this.BrokerProtocol;
146+
m_transport.MaxReceivedMessageSize = this.MaxMessageSize;
138147
BindingElementCollection elements = new BindingElementCollection();
139148

140149
if (m_transactionsEnabled)
@@ -163,12 +172,12 @@ private void Initialize()
163172
m_session = new ReliableSessionBindingElement();
164173
m_compositeDuplex = new CompositeDuplexBindingElement();
165174
m_transactionFlow = new TransactionFlowBindingElement();
166-
175+
m_maxMessageSize = 8192L;
167176
m_isInitialized = true;
168177
}
169178
}
170179
}
171-
180+
172181
/// <summary>
173182
/// Gets the scheme used by the binding, soap.amqp
174183
/// </summary>
@@ -197,6 +206,16 @@ public int Port
197206
set { m_port = value; }
198207
}
199208

209+
/// <summary>
210+
/// Specifies the maximum encoded message size
211+
/// </summary>
212+
[ConfigurationProperty("maxmessagesize")]
213+
public long MaxMessageSize
214+
{
215+
get { return m_maxMessageSize; }
216+
set { m_maxMessageSize = value; }
217+
}
218+
200219
/// <summary>
201220
/// Specifies the version of the AMQP protocol that should be used to communicate with the broker
202221
/// </summary>
@@ -223,7 +242,7 @@ public ReliableSession ReliableSession
223242
}
224243

225244
/// <summary>
226-
/// Determines whether or not the TransactionFlowBindingElement will
245+
/// Determines whether or not the TransactionFlowBindingElement will
227246
/// be added to the channel stack
228247
/// </summary>
229248
public bool TransactionFlow

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

Lines changed: 12 additions & 0 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;
@@ -113,6 +114,7 @@ protected override void OnApplyConfiguration(Binding binding)
113114
rabbind.Transport.Password = this.Password;
114115
rabbind.Transport.Username = this.Username;
115116
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: 11 additions & 0 deletions
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;
@@ -80,6 +81,7 @@ private RabbitMQTransportBindingElement(RabbitMQTransportBindingElement other)
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)