Skip to content

Commit e18c583

Browse files
Naming, cosmetics
1 parent 7d6e31e commit e18c583

File tree

7 files changed

+53
-30
lines changed

7 files changed

+53
-30
lines changed

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,18 @@ public virtual IConnection CreateConnection()
354354
/// <summary>
355355
/// Create a connection to the specified endpoint.
356356
/// </summary>
357-
/// <param name="connectionName">Connection name client property</param>
357+
/// <param name="clientProvidedName">
358+
/// Application-specific connection name, will be displayed in the management UI
359+
/// if RabbitMQ server supports it. This value doesn't have to be unique and cannot
360+
/// be used as a connection identifier, e.g. in HTTP API requests.
361+
/// This value is supposed to be human-readable.
362+
/// </param>
358363
/// <exception cref="BrokerUnreachableException">
359364
/// When the configured hostname was not reachable.
360365
/// </exception>
361-
public IConnection CreateConnection(String connectionName)
366+
public IConnection CreateConnection(String clientProvidedName)
362367
{
363-
return CreateConnection(new List<string>() { HostName }, connectionName);
368+
return CreateConnection(new List<string>() { HostName }, clientProvidedName);
364369
}
365370

366371
/// <summary>
@@ -390,26 +395,31 @@ public IConnection CreateConnection(IList<string> hostnames)
390395
/// List of hostnames to use for the initial
391396
/// connection and recovery.
392397
/// </param>
393-
/// <param name="connectionName">Connection name client property</param>
398+
/// <param name="clientProvidedName">
399+
/// Application-specific connection name, will be displayed in the management UI
400+
/// if RabbitMQ server supports it. This value doesn't have to be unique and cannot
401+
/// be used as a connection identifier, e.g. in HTTP API requests.
402+
/// This value is supposed to be human-readable.
403+
/// </param>
394404
/// <returns>Open connection</returns>
395405
/// <exception cref="BrokerUnreachableException">
396406
/// When no hostname was reachable.
397407
/// </exception>
398-
public IConnection CreateConnection(IList<string> hostnames, String connectionName)
408+
public IConnection CreateConnection(IList<string> hostnames, String clientProvidedName)
399409
{
400410
IConnection conn;
401411
try
402412
{
403413
if (AutomaticRecoveryEnabled)
404414
{
405-
var autorecoveringConnection = new AutorecoveringConnection(this, connectionName);
415+
var autorecoveringConnection = new AutorecoveringConnection(this, clientProvidedName);
406416
autorecoveringConnection.Init(hostnames);
407417
conn = autorecoveringConnection;
408418
}
409419
else
410420
{
411421
IProtocol protocol = Protocols.DefaultProtocol;
412-
conn = protocol.CreateConnection(this, false, CreateFrameHandler(), connectionName);
422+
conn = protocol.CreateConnection(this, false, CreateFrameHandler(), clientProvidedName);
413423
}
414424
}
415425
catch (Exception e)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,12 @@ public interface IConnection : NetworkConnection, IDisposable
153153
IList<ShutdownReportEntry> ShutdownReport { get; }
154154

155155
/// <summary>
156-
/// Returns connection name from client properties
156+
/// Application-specific connection name, will be displayed in the management UI
157+
/// if RabbitMQ server supports it. This value doesn't have to be unique and cannot
158+
/// be used as a connection identifier, e.g. in HTTP API requests.
159+
/// This value is supposed to be human-readable.
157160
/// </summary>
158-
String ConnectionName { get; }
161+
string ClientProvidedName { get; }
159162

160163
/// <summary>
161164
/// Signalled when an exception occurs in a callback invoked by the connection.

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,13 @@ public interface IConnectionFactory
100100
/// <summary>
101101
/// Create a connection to the specified endpoint.
102102
/// </summary>
103-
/// <param name="connectionName">Connection name client property</param>
103+
/// <param name="clientProvidedName"> /// Application-specific connection name, will be displayed in the management UI
104+
/// if RabbitMQ server supports it. This value doesn't have to be unique and cannot
105+
/// be used as a connection identifier, e.g. in HTTP API requests.
106+
/// This value is supposed to be human-readable.
107+
/// </param>
104108
/// <returns></returns>
105-
IConnection CreateConnection(String connectionName);
109+
IConnection CreateConnection(String clientProvidedName);
106110

107111
/// <summary>
108112
/// Connects to the first reachable hostname from the list.
@@ -115,9 +119,14 @@ public interface IConnectionFactory
115119
/// Connects to the first reachable hostname from the list.
116120
/// </summary>
117121
/// <param name="hostnames">List of host names to use</param>
118-
/// <param name="connectionName">Connection name client property</param>
122+
/// <param name="clientProvidedName">
123+
/// Application-specific connection name, will be displayed in the management UI
124+
/// if RabbitMQ server supports it. This value doesn't have to be unique and cannot
125+
/// be used as a connection identifier, e.g. in HTTP API requests.
126+
/// This value is supposed to be human-readable.
127+
/// </param>
119128
/// <returns></returns>
120-
IConnection CreateConnection(IList<string> hostnames, String connectionName);
129+
IConnection CreateConnection(IList<string> hostnames, String clientProvidedName);
121130

122131
/// <summary>
123132
/// Advanced option.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ public interface IProtocol
9797

9898
/// <summary>
9999
/// Construct a connection from a given set of parameters,
100-
/// a frame handler, and no automatic recovery.
100+
/// a frame handler, a client-provided name, and no automatic recovery.
101101
/// The "insist" parameter is passed on to the AMQP connection.open method.
102102
/// </summary>
103-
IConnection CreateConnection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, String connectionName);
103+
IConnection CreateConnection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, String clientProvidedName);
104104

105105
/// <summary>
106106
/// Construct a connection from a given set of parameters,
107-
/// a frame handler, and automatic recovery settings.
107+
/// a frame handler, a client-provided name, and automatic recovery settings.
108108
/// </summary>
109-
IConnection CreateConnection(ConnectionFactory factory, IFrameHandler frameHandler, bool automaticRecoveryEnabled, String connectionName);
109+
IConnection CreateConnection(ConnectionFactory factory, IFrameHandler frameHandler, bool automaticRecoveryEnabled, String clientProvidedName);
110110

111111
/// <summary>
112112
/// Construct a frame handler for a given endpoint.

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class AutorecoveringConnection : IConnection, IRecoverable
6868
protected bool manuallyClosed = false;
6969
protected bool performingRecovery = false;
7070

71+
7172
protected List<AutorecoveringModel> m_models = new List<AutorecoveringModel>();
7273

7374
protected HashSet<RecordedBinding> m_recordedBindings = new HashSet<RecordedBinding>();
@@ -94,10 +95,10 @@ public class AutorecoveringConnection : IConnection, IRecoverable
9495
private EventHandler<QueueNameChangedAfterRecoveryEventArgs> m_queueNameChange;
9596
private EventHandler<EventArgs> m_recovery;
9697

97-
public AutorecoveringConnection(ConnectionFactory factory, String connectionName = null)
98+
public AutorecoveringConnection(ConnectionFactory factory, string clientProvidedName = null)
9899
{
99100
m_factory = factory;
100-
ConnectionName = connectionName;
101+
this.ClientProvidedName = clientProvidedName;
101102
}
102103

103104
public event EventHandler<CallbackExceptionEventArgs> CallbackException
@@ -232,7 +233,7 @@ public event EventHandler<EventArgs> Recovery
232233
}
233234
}
234235

235-
public String ConnectionName { get; private set; }
236+
public string ClientProvidedName { get; private set; }
236237

237238
public bool AutoClose
238239
{
@@ -579,7 +580,7 @@ protected void Init(string hostname)
579580
{
580581
m_delegate = new Connection(m_factory, false,
581582
m_factory.CreateFrameHandlerForHostname(hostname),
582-
ConnectionName);
583+
this.ClientProvidedName);
583584

584585
AutorecoveringConnection self = this;
585586
EventHandler<ShutdownEventArgs> recoveryListener = (_, args) =>
@@ -796,7 +797,7 @@ protected void RecoverConnectionDelegate()
796797
{
797798
var nextHostname = m_factory.HostnameSelector.NextFrom(this.hostnames);
798799
var fh = m_factory.CreateFrameHandler(m_factory.Endpoint.CloneWithHostname(nextHostname));
799-
m_delegate = new Connection(m_factory, false, fh, ConnectionName);
800+
m_delegate = new Connection(m_factory, false, fh, this.ClientProvidedName);
800801
recovering = false;
801802
}
802803
catch (Exception e)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ public class Connection : IConnection
113113

114114
public ConsumerWorkService ConsumerWorkService { get; private set; }
115115

116-
public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, String connectionName = null)
116+
public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, string clientProvidedName = null)
117117
{
118-
ConnectionName = connectionName;
118+
clientProvidedName = clientProvidedName;
119119
KnownHosts = null;
120120
FrameMax = 0;
121121
m_factory = factory;
@@ -226,7 +226,7 @@ public event EventHandler<EventArgs> ConnectionUnblocked
226226
}
227227
}
228228

229-
public String ConnectionName { get; private set; }
229+
public string ClientProvidedName { get; private set; }
230230

231231
public bool AutoClose
232232
{
@@ -1277,7 +1277,7 @@ protected void StartAndTune()
12771277

12781278
m_clientProperties = new Dictionary<string, object>(m_factory.ClientProperties);
12791279
m_clientProperties["capabilities"] = Protocol.Capabilities;
1280-
m_clientProperties["connection_name"] = ConnectionName;
1280+
m_clientProperties["connection_name"] = this.ClientProvidedName;
12811281

12821282
// FIXME: parse out locales properly!
12831283
ConnectionTuneDetails connectionTune = default(ConnectionTuneDetails);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ public IConnection CreateConnection(IConnectionFactory factory,
138138
public IConnection CreateConnection(IConnectionFactory factory,
139139
bool insist,
140140
IFrameHandler frameHandler,
141-
String connectionName)
141+
string clientProvidedName)
142142
{
143-
return new Connection(factory, insist, frameHandler, connectionName);
143+
return new Connection(factory, insist, frameHandler, clientProvidedName);
144144
}
145145

146146
public IConnection CreateConnection(ConnectionFactory factory,
@@ -155,9 +155,9 @@ public IConnection CreateConnection(ConnectionFactory factory,
155155
public IConnection CreateConnection(ConnectionFactory factory,
156156
IFrameHandler frameHandler,
157157
bool automaticRecoveryEnabled,
158-
String connectionName)
158+
string clientProvidedName)
159159
{
160-
var ac = new AutorecoveringConnection(factory, connectionName);
160+
var ac = new AutorecoveringConnection(factory, clientProvidedName);
161161
ac.Init();
162162
return ac;
163163
}

0 commit comments

Comments
 (0)