Skip to content

Commit

Permalink
Merge bug24134 into default
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon MacMullen committed Jun 9, 2011
2 parents 80810f1 + 2afdfe5 commit f715f26
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 12 deletions.
Binary file modified docs/RabbitMQ Service Model.doc
Binary file not shown.
Binary file modified docs/RabbitMQ Service Model.docx
Binary file not shown.
Binary file modified docs/RabbitMQ Service Model.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<Reference Include="System.Data" />
<Reference Include="System.ServiceModel"><RequiredTargetFramework>3.0</RequiredTargetFramework></Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Runtime.Serialization" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\client\RabbitMQ.Client\RabbitMQ.Client.csproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,22 @@ public sealed class RabbitMQBinding : Binding
{
private String m_host;
private int m_port;
private long m_maxMessageSize;
private IProtocol m_brokerProtocol;
private CompositeDuplexBindingElement m_compositeDuplex;
private MessageEncodingBindingElement m_encoding;
private TextMessageEncodingBindingElement m_encoding;
private bool m_isInitialized;
private bool m_oneWayOnly;
private ReliableSessionBindingElement m_session;
private TransactionFlowBindingElement m_transactionFlow;
private bool m_transactionsEnabled;
private RabbitMQTransportBindingElement m_transport;

public static readonly long DefaultMaxMessageSize = 8192L;

/// <summary>
/// Creates a new instance of the RabbitMQBinding class initialized
/// to use the Protocols.DefaultProtocol. The broker must be set
/// Creates a new instance of the RabbitMQBinding class initialized
/// to use the Protocols.DefaultProtocol. The broker must be set
/// before use.
/// </summary>
public RabbitMQBinding()
Expand All @@ -89,7 +92,7 @@ public RabbitMQBinding(String hostname, int port)
/// Uses the broker and protocol specified
/// </summary>
/// <param name="hostname">The hostname of the broker to connect to</param>
/// <param name="port">The port of the broker to connect to</param>
/// <param name="port">The port of the broker to connect to</param>
/// <param name="protocol">The protocol version to use</param>
public RabbitMQBinding(String hostname, int port, IProtocol protocol)
: this(protocol)
Expand All @@ -98,6 +101,30 @@ public RabbitMQBinding(String hostname, int port, IProtocol protocol)
this.Port = port;
}

/// <summary>
/// Uses the broker, login and protocol specified
/// </summary>
/// <param name="hostname">The hostname of the broker to connect to</param>
/// <param name="port">The port of the broker to connect to</param>
/// <param name="username">The broker username to connect with</param>
/// <param name="password">The broker password to connect with</param>
/// <param name="virtualhost">The broker virtual host</param>
/// <param name="maxMessageSize">The largest allowable encoded message size</param>
/// <param name="protocol">The protocol version to use</param>
public RabbitMQBinding(String hostname, int port,
String username, String password, String virtualhost,
long maxMessageSize, IProtocol protocol)
: this(protocol)
{
this.HostName = hostname;
this.Port = port;
this.Transport.Username = username;
this.Transport.Password = password;
this.Transport.VirtualHost = virtualhost;
this.MaxMessageSize = maxMessageSize;

}

/// <summary>
/// Uses the specified protocol. The broker must be set before use.
/// </summary>
Expand All @@ -118,6 +145,10 @@ public override BindingElementCollection CreateBindingElements()
m_transport.HostName = this.HostName;
m_transport.Port = this.Port;
m_transport.BrokerProtocol = this.BrokerProtocol;
if (MaxMessageSize != DefaultMaxMessageSize)
{
m_transport.MaxReceivedMessageSize = MaxMessageSize;
}
BindingElementCollection elements = new BindingElementCollection();

if (m_transactionsEnabled)
Expand Down Expand Up @@ -146,12 +177,12 @@ private void Initialize()
m_session = new ReliableSessionBindingElement();
m_compositeDuplex = new CompositeDuplexBindingElement();
m_transactionFlow = new TransactionFlowBindingElement();

m_maxMessageSize = DefaultMaxMessageSize;
m_isInitialized = true;
}
}
}

/// <summary>
/// Gets the scheme used by the binding, soap.amqp
/// </summary>
Expand Down Expand Up @@ -180,6 +211,16 @@ public int Port
set { m_port = value; }
}

/// <summary>
/// Specifies the maximum encoded message size
/// </summary>
[ConfigurationProperty("maxmessagesize")]
public long MaxMessageSize
{
get { return m_maxMessageSize; }
set { m_maxMessageSize = value; }
}

/// <summary>
/// Specifies the version of the AMQP protocol that should be used to communicate with the broker
/// </summary>
Expand All @@ -206,7 +247,7 @@ public ReliableSession ReliableSession
}

/// <summary>
/// Determines whether or not the TransactionFlowBindingElement will
/// Determines whether or not the TransactionFlowBindingElement will
/// be added to the channel stack
/// </summary>
public bool TransactionFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ protected override void InitializeFrom(Binding binding)
{
this.HostName = rabbind.HostName;
this.Port = rabbind.Port;
this.MaxMessageSize = rabbind.MaxMessageSize;
this.OneWayOnly = rabbind.OneWayOnly;
this.TransactionFlowEnabled = rabbind.TransactionFlow;
this.VirtualHost = rabbind.Transport.ConnectionFactory.VirtualHost;
Expand Down Expand Up @@ -110,9 +111,10 @@ protected override void OnApplyConfiguration(Binding binding)
rabbind.BrokerProtocol = this.Protocol;
rabbind.OneWayOnly = this.OneWayOnly;
rabbind.TransactionFlow = this.TransactionFlowEnabled;
rabbind.Transport.ConnectionFactory.Password = this.Password;
rabbind.Transport.ConnectionFactory.UserName = this.Username;
rabbind.Transport.ConnectionFactory.VirtualHost = this.VirtualHost;
rabbind.Transport.Password = this.Password;
rabbind.Transport.Username = this.Username;
rabbind.Transport.VirtualHost = this.VirtualHost;
rabbind.Transport.MaxReceivedMessageSize = this.MaxMessageSize;
}

/// <summary>
Expand Down Expand Up @@ -191,6 +193,16 @@ public string ProtocolVersion
}
}

/// <summary>
/// Specifies the maximum encoded message size
/// </summary>
[ConfigurationProperty("maxmessagesize", DefaultValue = 8192L)]
public long MaxMessageSize
{
get { return (long)base["maxmessagesize"]; }
set { base["maxmessagesize"] = value; }
}

private IProtocol GetProtocol() {
IProtocol result = Protocols.Lookup(this.ProtocolVersion);
if (result == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public RabbitMQInputChannel(BindingContext context, IModel model, EndpointAddres
: base(context, address)
{
m_bindingElement = context.Binding.Elements.Find<RabbitMQTransportBindingElement>();
MessageEncodingBindingElement encoderElem = context.BindingParameters.Find<MessageEncodingBindingElement>();
TextMessageEncodingBindingElement encoderElem = context.BindingParameters.Find<TextMessageEncodingBindingElement>();
encoderElem.ReaderQuotas.MaxStringContentLength = (int)m_bindingElement.MaxReceivedMessageSize;
if (encoderElem != null) {
m_encoder = encoderElem.CreateMessageEncoderFactory().Encoder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public sealed class RabbitMQTransportBindingElement : TransportBindingElement
private IProtocol m_protocol;
private String m_host;
private int m_port;
private long m_maxReceivedMessageSize;
private String m_username;
private String m_password;
private String m_vhost;
Expand All @@ -69,17 +70,18 @@ public sealed class RabbitMQTransportBindingElement : TransportBindingElement
/// </summary>
public RabbitMQTransportBindingElement()
{
MaxReceivedMessageSize = RabbitMQBinding.DefaultMaxMessageSize;
}

private RabbitMQTransportBindingElement(RabbitMQTransportBindingElement other)
: this()
{
HostName = other.HostName;
Port = other.Port;
BrokerProtocol = other.BrokerProtocol;
Username = other.Username;
Password = other.Password;
VirtualHost = other.VirtualHost;
MaxReceivedMessageSize = other.MaxReceivedMessageSize;
}


Expand Down Expand Up @@ -190,6 +192,15 @@ public int Port
}
}

/// <summary>
/// The largest receivable encoded message
/// </summary>
public override long MaxReceivedMessageSize
{
get { return m_maxReceivedMessageSize; }
set { m_maxReceivedMessageSize = value; }
}

/// <summary>
/// The username to use when authenticating with the broker
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ public string VirtualHost
set { base["virtualHost"] = value; }
}

/// <summary>
/// The largest receivable encoded message
/// </summary>
public new long MaxReceivedMessageSize
{
get { return MaxReceivedMessageSize; }
set { MaxReceivedMessageSize = value; }
}

protected override ConfigurationPropertyCollection Properties
{
get
Expand Down

0 comments on commit f715f26

Please sign in to comment.