Skip to content

Commit 43c1429

Browse files
author
Matthew Sackman
committed
Reverting changeset erroneously commited on wrong branch
1 parent b845632 commit 43c1429

File tree

3 files changed

+81
-130
lines changed

3 files changed

+81
-130
lines changed

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,11 @@ public class AMQPParameters : ICloneable
9090
private uint m_requestedFrameMax = DefaultFrameMax;
9191
private ushort m_requestedHeartbeat = DefaultHeartbeat;
9292
private SslOption m_ssl = new SslOption();
93-
private IProtocol m_protocol;
9493

9594
///<summary>Construct a fresh instance, with all fields set to
9695
///their respective defaults.</summary>
9796
public AMQPParameters() { }
9897

99-
///<summary>Retrieve or set the IProtocol of this AmqpTcpEndpoint.</summary>
100-
public IProtocol Protocol
101-
{
102-
get { return m_protocol; }
103-
set { m_protocol = value; }
104-
}
105-
106-
private string m_hostName;
107-
///<summary>Retrieve or set the hostname of this AmqpTcpEndpoint.</summary>
108-
public string HostName
109-
{
110-
get { return m_hostName; }
111-
set { m_hostName = value; }
112-
}
113-
11498
/// <summary>Username to use when authenticating to the server</summary>
11599
public string UserName
116100
{

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

Lines changed: 81 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,17 @@ namespace RabbitMQ.Client
103103
///</remarks>
104104
public class ConnectionFactory
105105
{
106-
public ConnectionParameters[] ConnectionParameters = { new ConnectionParameters() };
107-
106+
private AMQPParameters m_parameters = new AMQPParameters();
107+
///<summary>Retrieve the parameters this factory uses to
108+
///construct IConnection instances.</summary>
109+
public AMQPParameters Parameters
110+
{
111+
get
112+
{
113+
return m_parameters;
114+
}
115+
}
116+
108117
///<summary>Constructs a ConnectionFactory with default values
109118
///for Parameters.</summary>
110119
public ConnectionFactory()
@@ -115,10 +124,10 @@ protected virtual IConnection FollowRedirectChain
115124
(int maxRedirects,
116125
IDictionary connectionAttempts,
117126
IDictionary connectionErrors,
118-
ref ConnectionParameters[] mostRecentKnownHosts,
119-
ConnectionParameters endpoint)
127+
ref AmqpTcpEndpoint[] mostRecentKnownHosts,
128+
AmqpTcpEndpoint endpoint)
120129
{
121-
ConnectionParameters candidate = endpoint;
130+
AmqpTcpEndpoint candidate = endpoint;
122131
try {
123132
while (true) {
124133
int attemptCount =
@@ -129,13 +138,13 @@ protected virtual IConnection FollowRedirectChain
129138
bool insist = attemptCount >= maxRedirects;
130139

131140
try {
132-
IProtocol p = candidate.AMQP.Protocol;
133-
IFrameHandler fh = p.CreateFrameHandler(candidate.TCP);
141+
IProtocol p = candidate.Protocol;
142+
IFrameHandler fh = p.CreateFrameHandler(candidate);
134143
// At this point, we may be able to create
135144
// and fully open a successful connection,
136145
// in which case we're done, and the
137146
// connection should be returned.
138-
return p.CreateConnection(candidate.AMQP, insist, fh);
147+
return p.CreateConnection(m_parameters, insist, fh);
139148
} catch (RedirectException re) {
140149
if (insist) {
141150
// We've been redirected, but we insisted that
@@ -151,12 +160,9 @@ protected virtual IConnection FollowRedirectChain
151160
// mostRecentKnownHosts (in case the chain
152161
// runs out), and updating candidate for the
153162
// next time round the loop.
154-
connectionErrors[candidate] = re;
155-
mostRecentKnownHosts = new ConnectionParameters[re.KnownHosts.Length];
156-
for(int i = 0; i < re.KnownHosts.Length; i++){
157-
mostRecentKnownHosts[i] = new ConnectionParameters(candidate.AMQP, re.KnownHosts[i]);
158-
}
159-
candidate = new ConnectionParameters(candidate.AMQP, re.Host);
163+
connectionErrors[candidate] = re;
164+
mostRecentKnownHosts = re.KnownHosts;
165+
candidate = re.Host;
160166
}
161167
}
162168
}
@@ -169,14 +175,13 @@ protected virtual IConnection FollowRedirectChain
169175
protected virtual IConnection CreateConnection(int maxRedirects,
170176
IDictionary connectionAttempts,
171177
IDictionary connectionErrors,
172-
ConnectionParameters[] endpoints)
178+
params AmqpTcpEndpoint[] endpoints)
173179
{
174-
foreach (ConnectionParameters endpoint in endpoints)
180+
foreach (AmqpTcpEndpoint endpoint in endpoints)
175181
{
176-
ConnectionParameters[] mostRecentKnownHosts = new ConnectionParameters[0];
182+
AmqpTcpEndpoint[] mostRecentKnownHosts = new AmqpTcpEndpoint[0];
177183
// ^^ holds a list of known-hosts that came back with
178-
// a connection.redirect, together with the AMQPParameters
179-
// used for that connection attempt. If, once we reach the end of
184+
// a connection.redirect. If, once we reach the end of
180185
// a chain of redirects, we still haven't managed to
181186
// get a usable connection, we recurse on
182187
// mostRecentKnownHosts, trying each of those in
@@ -225,14 +230,15 @@ protected virtual IConnection CreateConnection(int maxRedirects,
225230
///endpoint in the list provided. Up to a maximum of
226231
///maxRedirects broker-originated redirects are permitted for
227232
///each endpoint tried.</summary>
228-
public virtual IConnection CreateConnection(int maxRedirects)
233+
public virtual IConnection CreateConnection(int maxRedirects,
234+
params AmqpTcpEndpoint[] endpoints)
229235
{
230236
IDictionary connectionAttempts = new Hashtable();
231237
IDictionary connectionErrors = new Hashtable();
232238
IConnection conn = CreateConnection(maxRedirects,
233239
connectionAttempts,
234240
connectionErrors,
235-
ConnectionParameters);
241+
endpoints);
236242
if (conn != null) {
237243
return conn;
238244
}
@@ -242,9 +248,61 @@ public virtual IConnection CreateConnection(int maxRedirects)
242248
///<summary>Create a connection to the first available
243249
///endpoint in the list provided. No broker-originated
244250
///redirects are permitted.</summary>
245-
public virtual IConnection CreateConnection()
251+
public virtual IConnection CreateConnection(params AmqpTcpEndpoint[] endpoints)
246252
{
247-
return CreateConnection(0);
253+
return CreateConnection(0, endpoints);
254+
}
255+
256+
///<summary>Create a connection to the endpoint specified.</summary>
257+
///<exception cref="ArgumentException"/>
258+
public IConnection CreateConnection(IProtocol version,
259+
string hostName,
260+
int portNumber)
261+
{
262+
return CreateConnection(new AmqpTcpEndpoint(version,
263+
hostName,
264+
portNumber,
265+
m_parameters.Ssl));
266+
}
267+
268+
///<summary>Create a connection to the endpoint specified. The
269+
///port used is the default for the protocol.</summary>
270+
///<exception cref="ArgumentException"/>
271+
public IConnection CreateConnection(IProtocol version, string hostName)
272+
{
273+
return CreateConnection(new AmqpTcpEndpoint(version, hostName));
274+
}
275+
276+
///<summary>Create a connection to the endpoint specified.</summary>
277+
///<remarks>
278+
/// Please see the class overview documentation for
279+
/// information about the Uri format in use.
280+
///</remarks>
281+
///<exception cref="ArgumentException"/>
282+
public IConnection CreateConnection(IProtocol version, Uri uri)
283+
{
284+
return CreateConnection(new AmqpTcpEndpoint(version, uri));
285+
}
286+
287+
///<summary>Create a connection to the endpoint specified,
288+
///with the IProtocol from
289+
///Protocols.FromEnvironment().</summary>
290+
///<remarks>
291+
/// Please see the class overview documentation for
292+
/// information about the Uri format in use.
293+
///</remarks>
294+
public IConnection CreateConnection(Uri uri)
295+
{
296+
return CreateConnection(new AmqpTcpEndpoint(uri));
297+
}
298+
299+
///<summary>Create a connection to the host (and optional
300+
///port) specified, with the IProtocol from
301+
///Protocols.FromEnvironment(). The format of the address
302+
///string is the same as that accepted by
303+
///AmqpTcpEndpoint.Parse().</summary>
304+
public IConnection CreateConnection(string address) {
305+
return CreateConnection(AmqpTcpEndpoint.Parse(Protocols.FromEnvironment(), address));
248306
}
249307
}
250308
}

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

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)