Skip to content

Commit b68ac2c

Browse files
committed
Merge bug21949 into default
2 parents 727793e + 1eca6ca commit b68ac2c

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

projects/client/RabbitMQ.Client/src/client/api/ConnectionFactory.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace RabbitMQ.Client
8080
/// factory.VirtualHost = ConnectionFactory.DefaultVHost;
8181
/// factory.Protocol = Protocols.FromEnvironment();
8282
/// factory.HostName = hostName;
83-
// factory.PortNumber = AmqpTcpEndpoint.UseDefaultPort;
83+
/// factory.PortNumber = AmqpTcpEndpoint.UseDefaultPort;
8484
/// //
8585
/// IConnection conn = factory.CreateConnection();
8686
/// //
@@ -144,6 +144,10 @@ public class ConnectionFactory
144144
/// <summary>Heartbeat setting to request (in seconds)</summary>
145145
public ushort RequestedHeartbeat = DefaultHeartbeat;
146146

147+
/// <summary>Dictionary of client properties to be sent to the
148+
/// server</summary>
149+
public IDictionary ClientProperties = ConnectionBase.DefaultClientProperties();
150+
147151
///<summary>Ssl options setting</summary>
148152
public SslOption Ssl = new SslOption();
149153

projects/client/RabbitMQ.Client/src/client/api/IConnection.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ public interface IConnection: IDisposable
116116
///(0 for disabled), in seconds.</summary>
117117
ushort Heartbeat { get; }
118118

119+
///<summary>A copy of the client properties that has been sent to the
120+
///server.</summary>
121+
IDictionary ClientProperties { get; }
122+
119123
///<summary>A dictionary of the server properties sent by the server
120124
///while establishing the connection. This typically includes
121125
///the product name and version of the server.</summary>

projects/client/RabbitMQ.Client/src/client/impl/ConnectionBase.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public abstract class ConnectionBase : IConnection
9393
public IFrameHandler m_frameHandler;
9494
public uint m_frameMax = 0;
9595
public ushort m_heartbeat = 0;
96+
public IDictionary m_clientProperties;
9697
public IDictionary m_serverProperties;
9798
public AmqpTcpEndpoint[] m_knownHosts = null;
9899

@@ -251,6 +252,18 @@ public ushort Heartbeat
251252
}
252253
}
253254

255+
public IDictionary ClientProperties
256+
{
257+
get
258+
{
259+
return new Hashtable(m_clientProperties);
260+
}
261+
set
262+
{
263+
m_clientProperties = value;
264+
}
265+
}
266+
254267
public IDictionary ServerProperties
255268
{
256269
get
@@ -909,9 +922,11 @@ public void OnCallbackException(CallbackExceptionEventArgs args)
909922
}
910923
}
911924

912-
public IDictionary BuildClientPropertiesTable()
925+
public static IDictionary DefaultClientProperties()
913926
{
914-
string version = this.GetType().Assembly.GetName().Version.ToString();
927+
System.Reflection.Assembly assembly =
928+
System.Reflection.Assembly.GetAssembly(typeof(ConnectionBase));
929+
string version = assembly.GetName().Version.ToString();
915930
//TODO: Get the rest of this data from the Assembly Attributes
916931
Hashtable table = new Hashtable();
917932
table["product"] = Encoding.UTF8.GetBytes("RabbitMQ");
@@ -968,10 +983,12 @@ public void Open(bool insist)
968983
serverVersion.Minor);
969984
}
970985

986+
m_clientProperties = new Hashtable(m_factory.ClientProperties);
987+
971988
// FIXME: check that PLAIN is supported.
972989
// FIXME: parse out locales properly!
973990
ConnectionTuneDetails connectionTune =
974-
m_model0.ConnectionStartOk(BuildClientPropertiesTable(),
991+
m_model0.ConnectionStartOk(m_clientProperties,
975992
"PLAIN",
976993
Encoding.UTF8.GetBytes("\0" + m_factory.UserName +
977994
"\0" + m_factory.Password),

0 commit comments

Comments
 (0)