@@ -103,17 +103,8 @@ namespace RabbitMQ.Client
103
103
///</remarks>
104
104
public class ConnectionFactory
105
105
{
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
-
106
+ public ConnectionParameters [ ] ConnectionParameters = { new ConnectionParameters ( ) } ;
107
+
117
108
///<summary>Constructs a ConnectionFactory with default values
118
109
///for Parameters.</summary>
119
110
public ConnectionFactory ( )
@@ -124,10 +115,10 @@ protected virtual IConnection FollowRedirectChain
124
115
( int maxRedirects ,
125
116
IDictionary connectionAttempts ,
126
117
IDictionary connectionErrors ,
127
- ref AmqpTcpEndpoint [ ] mostRecentKnownHosts ,
128
- AmqpTcpEndpoint endpoint )
118
+ ref ConnectionParameters [ ] mostRecentKnownHosts ,
119
+ ConnectionParameters endpoint )
129
120
{
130
- AmqpTcpEndpoint candidate = endpoint ;
121
+ ConnectionParameters candidate = endpoint ;
131
122
try {
132
123
while ( true ) {
133
124
int attemptCount =
@@ -138,13 +129,13 @@ protected virtual IConnection FollowRedirectChain
138
129
bool insist = attemptCount >= maxRedirects ;
139
130
140
131
try {
141
- IProtocol p = candidate . Protocol ;
142
- IFrameHandler fh = p . CreateFrameHandler ( candidate ) ;
132
+ IProtocol p = candidate . AMQP . Protocol ;
133
+ IFrameHandler fh = p . CreateFrameHandler ( candidate . TCP ) ;
143
134
// At this point, we may be able to create
144
135
// and fully open a successful connection,
145
136
// in which case we're done, and the
146
137
// connection should be returned.
147
- return p . CreateConnection ( m_parameters , insist , fh ) ;
138
+ return p . CreateConnection ( candidate . AMQP , insist , fh ) ;
148
139
} catch ( RedirectException re ) {
149
140
if ( insist ) {
150
141
// We've been redirected, but we insisted that
@@ -160,9 +151,12 @@ protected virtual IConnection FollowRedirectChain
160
151
// mostRecentKnownHosts (in case the chain
161
152
// runs out), and updating candidate for the
162
153
// next time round the loop.
163
- connectionErrors [ candidate ] = re ;
164
- mostRecentKnownHosts = re . KnownHosts ;
165
- candidate = re . Host ;
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 ) ;
166
160
}
167
161
}
168
162
}
@@ -175,13 +169,14 @@ protected virtual IConnection FollowRedirectChain
175
169
protected virtual IConnection CreateConnection ( int maxRedirects ,
176
170
IDictionary connectionAttempts ,
177
171
IDictionary connectionErrors ,
178
- params AmqpTcpEndpoint [ ] endpoints )
172
+ ConnectionParameters [ ] endpoints )
179
173
{
180
- foreach ( AmqpTcpEndpoint endpoint in endpoints )
174
+ foreach ( ConnectionParameters endpoint in endpoints )
181
175
{
182
- AmqpTcpEndpoint [ ] mostRecentKnownHosts = new AmqpTcpEndpoint [ 0 ] ;
176
+ ConnectionParameters [ ] mostRecentKnownHosts = new ConnectionParameters [ 0 ] ;
183
177
// ^^ holds a list of known-hosts that came back with
184
- // a connection.redirect. If, once we reach the end of
178
+ // a connection.redirect, together with the AMQPParameters
179
+ // used for that connection attempt. If, once we reach the end of
185
180
// a chain of redirects, we still haven't managed to
186
181
// get a usable connection, we recurse on
187
182
// mostRecentKnownHosts, trying each of those in
@@ -230,15 +225,14 @@ protected virtual IConnection CreateConnection(int maxRedirects,
230
225
///endpoint in the list provided. Up to a maximum of
231
226
///maxRedirects broker-originated redirects are permitted for
232
227
///each endpoint tried.</summary>
233
- public virtual IConnection CreateConnection ( int maxRedirects ,
234
- params AmqpTcpEndpoint [ ] endpoints )
228
+ public virtual IConnection CreateConnection ( int maxRedirects )
235
229
{
236
230
IDictionary connectionAttempts = new Hashtable ( ) ;
237
231
IDictionary connectionErrors = new Hashtable ( ) ;
238
232
IConnection conn = CreateConnection ( maxRedirects ,
239
233
connectionAttempts ,
240
234
connectionErrors ,
241
- endpoints ) ;
235
+ ConnectionParameters ) ;
242
236
if ( conn != null ) {
243
237
return conn ;
244
238
}
@@ -248,61 +242,9 @@ public virtual IConnection CreateConnection(int maxRedirects,
248
242
///<summary>Create a connection to the first available
249
243
///endpoint in the list provided. No broker-originated
250
244
///redirects are permitted.</summary>
251
- public virtual IConnection CreateConnection ( params AmqpTcpEndpoint [ ] endpoints )
245
+ public virtual IConnection CreateConnection ( )
252
246
{
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 ) ) ;
247
+ return CreateConnection ( 0 ) ;
306
248
}
307
249
}
308
250
}
0 commit comments