Skip to content

Commit e8f0a3a

Browse files
Merge branch 'stable'
2 parents fb22759 + 5946a8b commit e8f0a3a

File tree

10 files changed

+134
-14
lines changed

10 files changed

+134
-14
lines changed

projects/client/RabbitMQ.Client.WinRT/RabbitMQ.Client.WinRT.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565
<Target Name="Detokenize" DependsOnTargets="CreateGensrcDir" Inputs="@(Tokenized); $(LocalPropsFile)" Outputs="@(Detokenized)">
6666
<Delete Files="@(Detokenized)" />
6767
<TemplateFile Template="$(AssemblyInfoTok)" OutputFilename="detok.out" Tokens="@(Tokens)" />
68-
<Move SourceFiles="src\tokenized\detok.out" DestinationFiles="$(AssemblyInfoDetok)" />
68+
<!-- <Move SourceFiles="src\tokenized\detok.out" DestinationFiles="$(AssemblyInfoDetok)" /> -->
69+
<Copy SourceFiles="src\tokenized\detok.out" DestinationFiles="$(AssemblyInfoDetok)" />
70+
<Delete Files="src\tokenized\detok.out" />
6971
</Target>
7072
<Target Name="CleanDetokenize">
7173
<Delete Files="@(Detokenized)" />

projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@
7272
<Target Name="Detokenize" DependsOnTargets="CreateGensrcDir" Inputs="@(Tokenized); $(LocalPropsFile)" Outputs="@(Detokenized)">
7373
<Delete Files="@(Detokenized)" />
7474
<TemplateFile Template="$(AssemblyInfoTok)" OutputFilename="detok.out" Tokens="@(Tokens)" />
75-
<Move SourceFiles="src\tokenized\detok.out" DestinationFiles="$(AssemblyInfoDetok)" />
75+
<!-- <Move SourceFiles="src\tokenized\detok.out" DestinationFiles="$(AssemblyInfoDetok)" /> -->
76+
<Copy SourceFiles="src\tokenized\detok.out" DestinationFiles="$(AssemblyInfoDetok)" />
77+
<Delete Files="src\tokenized\detok.out" />
7678
</Target>
7779
<Target Name="CleanDetokenize">
7880
<Delete Files="@(Detokenized)" />

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

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,24 @@ public AuthMechanismFactory AuthMechanismFactory(IList<string> mechanismNames)
348348
/// </exception>
349349
public virtual IConnection CreateConnection()
350350
{
351-
return CreateConnection(new List<string>() { HostName });
351+
return CreateConnection(new List<string>() { HostName }, null);
352+
}
353+
354+
/// <summary>
355+
/// Create a connection to the specified endpoint.
356+
/// </summary>
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>
363+
/// <exception cref="BrokerUnreachableException">
364+
/// When the configured hostname was not reachable.
365+
/// </exception>
366+
public IConnection CreateConnection(String clientProvidedName)
367+
{
368+
return CreateConnection(new List<string>() { HostName }, clientProvidedName);
352369
}
353370

354371
/// <summary>
@@ -365,20 +382,44 @@ public virtual IConnection CreateConnection()
365382
/// When no hostname was reachable.
366383
/// </exception>
367384
public IConnection CreateConnection(IList<string> hostnames)
385+
{
386+
return CreateConnection(hostnames, null);
387+
}
388+
389+
/// <summary>
390+
/// Create a connection using a list of hostnames. The first reachable
391+
/// hostname will be used initially. Subsequent hostname picks are determined
392+
/// by the <see cref="IHostnameSelector" /> configured.
393+
/// </summary>
394+
/// <param name="hostnames">
395+
/// List of hostnames to use for the initial
396+
/// connection and recovery.
397+
/// </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>
404+
/// <returns>Open connection</returns>
405+
/// <exception cref="BrokerUnreachableException">
406+
/// When no hostname was reachable.
407+
/// </exception>
408+
public IConnection CreateConnection(IList<string> hostnames, String clientProvidedName)
368409
{
369410
IConnection conn;
370411
try
371412
{
372413
if (AutomaticRecoveryEnabled)
373414
{
374-
var autorecoveringConnection = new AutorecoveringConnection(this);
415+
var autorecoveringConnection = new AutorecoveringConnection(this, clientProvidedName);
375416
autorecoveringConnection.Init(hostnames);
376417
conn = autorecoveringConnection;
377418
}
378419
else
379420
{
380421
IProtocol protocol = Protocols.DefaultProtocol;
381-
conn = protocol.CreateConnection(this, false, CreateFrameHandler());
422+
conn = protocol.CreateConnection(this, false, CreateFrameHandler(), clientProvidedName);
382423
}
383424
}
384425
catch (Exception e)

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ public interface IConnection : NetworkConnection, IDisposable
152152
/// </summary>
153153
IList<ShutdownReportEntry> ShutdownReport { get; }
154154

155+
/// <summary>
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.
160+
/// </summary>
161+
string ClientProvidedName { get; }
162+
155163
/// <summary>
156164
/// Signalled when an exception occurs in a callback invoked by the connection.
157165
/// </summary>

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,40 @@ public interface IConnectionFactory
9797
/// </summary>
9898
IConnection CreateConnection();
9999

100+
/// <summary>
101+
/// Create a connection to the specified endpoint.
102+
/// </summary>
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>
108+
/// <returns></returns>
109+
IConnection CreateConnection(String clientProvidedName);
110+
100111
/// <summary>
101112
/// Connects to the first reachable hostname from the list.
102113
/// </summary>
103114
/// <param name="hostnames">List of host names to use</param>
104115
/// <returns></returns>
105116
IConnection CreateConnection(IList<string> hostnames);
106117

118+
/// <summary>
119+
/// Connects to the first reachable hostname from the list.
120+
/// </summary>
121+
/// <param name="hostnames">List of host names to use</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>
128+
/// <returns></returns>
129+
IConnection CreateConnection(IList<string> hostnames, String clientProvidedName);
130+
107131
/// <summary>
108132
/// Advanced option.
109-
///
133+
///
110134
/// What task scheduler should consumer dispatcher use.
111135
/// </summary>
112136
TaskScheduler TaskScheduler { get; set; }

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ public interface IProtocol
9595
/// </summary>
9696
IConnection CreateConnection(ConnectionFactory factory, IFrameHandler frameHandler, bool automaticRecoveryEnabled);
9797

98+
/// <summary>
99+
/// Construct a connection from a given set of parameters,
100+
/// a frame handler, a client-provided name, and no automatic recovery.
101+
/// The "insist" parameter is passed on to the AMQP connection.open method.
102+
/// </summary>
103+
IConnection CreateConnection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, String clientProvidedName);
104+
105+
/// <summary>
106+
/// Construct a connection from a given set of parameters,
107+
/// a frame handler, a client-provided name, and automatic recovery settings.
108+
/// </summary>
109+
IConnection CreateConnection(ConnectionFactory factory, IFrameHandler frameHandler, bool automaticRecoveryEnabled, String clientProvidedName);
110+
98111
/// <summary>
99112
/// Construct a frame handler for a given endpoint.
100113
/// </summary>

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

Lines changed: 8 additions & 3 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,9 +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)
98+
public AutorecoveringConnection(ConnectionFactory factory, string clientProvidedName = null)
9899
{
99100
m_factory = factory;
101+
this.ClientProvidedName = clientProvidedName;
100102
}
101103

102104
public event EventHandler<CallbackExceptionEventArgs> CallbackException
@@ -231,6 +233,8 @@ public event EventHandler<EventArgs> Recovery
231233
}
232234
}
233235

236+
public string ClientProvidedName { get; private set; }
237+
234238
public bool AutoClose
235239
{
236240
get { return m_delegate.AutoClose; }
@@ -575,7 +579,8 @@ public void Init(IList<string> hostnames)
575579
protected void Init(string hostname)
576580
{
577581
m_delegate = new Connection(m_factory, false,
578-
m_factory.CreateFrameHandlerForHostname(hostname));
582+
m_factory.CreateFrameHandlerForHostname(hostname),
583+
this.ClientProvidedName);
579584

580585
AutorecoveringConnection self = this;
581586
EventHandler<ShutdownEventArgs> recoveryListener = (_, args) =>
@@ -792,7 +797,7 @@ protected void RecoverConnectionDelegate()
792797
{
793798
var nextHostname = m_factory.HostnameSelector.NextFrom(this.hostnames);
794799
var fh = m_factory.CreateFrameHandler(m_factory.Endpoint.CloneWithHostname(nextHostname));
795-
m_delegate = new Connection(m_factory, false, fh);
800+
m_delegate = new Connection(m_factory, false, fh, this.ClientProvidedName);
796801
recovering = false;
797802
}
798803
catch (Exception e)

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

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

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

116-
public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler)
116+
public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, string clientProvidedName = null)
117117
{
118+
clientProvidedName = clientProvidedName;
118119
KnownHosts = null;
119120
FrameMax = 0;
120121
m_factory = factory;
@@ -225,6 +226,8 @@ public event EventHandler<EventArgs> ConnectionUnblocked
225226
}
226227
}
227228

229+
public string ClientProvidedName { get; private set; }
230+
228231
public bool AutoClose
229232
{
230233
get { return m_sessionManager.AutoClose; }
@@ -995,7 +998,7 @@ public void MaybeStartHeartbeatTimers()
995998
_heartbeatWriteTimer = new Timer(HeartbeatWriteTimerCallback);
996999
_heartbeatReadTimer = new Timer(HeartbeatReadTimerCallback);
9971000
#if NETFX_CORE
998-
_heartbeatWriteTimer.Change(200, m_heartbeatTimeSpan.Milliseconds);
1001+
_heartbeatWriteTimer.Change(200, m_heartbeatTimeSpan.Milliseconds);
9991002
_heartbeatReadTimer.Change(200, m_heartbeatTimeSpan.Milliseconds);
10001003
#else
10011004
_heartbeatWriteTimer.Change(TimeSpan.FromMilliseconds(200), m_heartbeatTimeSpan);
@@ -1274,6 +1277,7 @@ protected void StartAndTune()
12741277

12751278
m_clientProperties = new Dictionary<string, object>(m_factory.ClientProperties);
12761279
m_clientProperties["capabilities"] = Protocol.Capabilities;
1280+
m_clientProperties["connection_name"] = this.ClientProvidedName;
12771281

12781282
// FIXME: parse out locales properly!
12791283
ConnectionTuneDetails connectionTune = default(ConnectionTuneDetails);

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,33 @@ public IConnection CreateConnection(IConnectionFactory factory,
131131
bool insist,
132132
IFrameHandler frameHandler)
133133
{
134-
return new Connection(factory, insist, frameHandler);
134+
return new Connection(factory, insist, frameHandler, null);
135+
}
136+
137+
138+
public IConnection CreateConnection(IConnectionFactory factory,
139+
bool insist,
140+
IFrameHandler frameHandler,
141+
string clientProvidedName)
142+
{
143+
return new Connection(factory, insist, frameHandler, clientProvidedName);
135144
}
136145

137146
public IConnection CreateConnection(ConnectionFactory factory,
138147
IFrameHandler frameHandler,
139148
bool automaticRecoveryEnabled)
140149
{
141-
var ac = new AutorecoveringConnection(factory);
150+
var ac = new AutorecoveringConnection(factory, null);
151+
ac.Init();
152+
return ac;
153+
}
154+
155+
public IConnection CreateConnection(ConnectionFactory factory,
156+
IFrameHandler frameHandler,
157+
bool automaticRecoveryEnabled,
158+
string clientProvidedName)
159+
{
160+
var ac = new AutorecoveringConnection(factory, clientProvidedName);
142161
ac.Init();
143162
return ac;
144163
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
<Target Name="Detokenize" DependsOnTargets="CreateGensrcDir" Inputs="@(Tokenized); $(LocalPropsFile)" Outputs="@(Detokenized)">
4747
<Delete Files="@(Detokenized)" />
4848
<TemplateFile Template="$(AssemblyInfoTok)" OutputFilename="detok.out" Tokens="@(Tokens)" />
49-
<Move SourceFiles="src\tokenized\detok.out" DestinationFiles="$(AssemblyInfoDetok)" />
49+
<!-- <Move SourceFiles="src\tokenized\detok.out" DestinationFiles="$(AssemblyInfoDetok)" /> -->
50+
<Copy SourceFiles="src\tokenized\detok.out" DestinationFiles="$(AssemblyInfoDetok)" />
51+
<Delete Files="src\tokenized\detok.out" />
5052
</Target>
5153
<Target Name="CleanDetokenize">
5254
<Delete Files="@(Detokenized)" />

0 commit comments

Comments
 (0)