@@ -78,12 +78,11 @@ namespace RabbitMQ.Client
78
78
/// factory.UserName = ConnectionFactory.DefaultUser;
79
79
/// factory.Password = ConnectionFactory.DefaultPass;
80
80
/// factory.VirtualHost = ConnectionFactory.DefaultVHost;
81
- /// factory.Protocol = Protocols.DefaultProtocol ;
81
+ /// factory.Protocol = Protocols.FromEnvironment() ;
82
82
/// factory.HostName = hostName;
83
- // factory.PortNumber = portNumber ;
83
+ // factory.PortNumber = AmqpTcpEndpoint.UseDefaultPort ;
84
84
/// //
85
- /// IProtocol protocol = Protocols.DefaultProtocol;
86
- /// IConnection conn = factory.CreateConnection(protocol, hostName, portNumber);
85
+ /// IConnection conn = factory.CreateConnection();
87
86
/// //
88
87
/// IModel ch = conn.CreateModel();
89
88
/// //
@@ -148,6 +147,31 @@ public class ConnectionFactory
148
147
///<summary>Ssl options setting</summary>
149
148
public SslOption Ssl = new SslOption ( ) ;
150
149
150
+ ///<summary>The host to connect to</summary>
151
+ public String HostName = "localhost" ;
152
+
153
+ ///<summary>The port to connect on. AmqpTcpEndpoint.UseDefaultPort indicates the
154
+ /// default for the protocol should be used.</summary>
155
+ public int Port = AmqpTcpEndpoint . UseDefaultPort ;
156
+
157
+ ///<summary>The AMQP protocol to be used</summary>
158
+ public IProtocol Protocol = Protocols . FromEnvironment ( ) ;
159
+
160
+
161
+ public AmqpTcpEndpoint Endpoint
162
+ {
163
+ get
164
+ {
165
+ return new AmqpTcpEndpoint ( Protocol , HostName , Port ) ;
166
+ }
167
+ set
168
+ {
169
+ Protocol = value . Protocol ;
170
+ Port = value . Port ;
171
+ HostName = value . HostName ;
172
+ }
173
+ }
174
+
151
175
///<summary>Construct a fresh instance, with all fields set to
152
176
///their respective defaults.</summary>
153
177
public ConnectionFactory ( ) { }
@@ -262,79 +286,25 @@ protected virtual IConnection CreateConnection(int maxRedirects,
262
286
///endpoint in the list provided. Up to a maximum of
263
287
///maxRedirects broker-originated redirects are permitted for
264
288
///each endpoint tried.</summary>
265
- public virtual IConnection CreateConnection ( int maxRedirects ,
266
- params AmqpTcpEndpoint [ ] endpoints )
289
+ public virtual IConnection CreateConnection ( int maxRedirects )
267
290
{
268
291
IDictionary connectionAttempts = new Hashtable ( ) ;
269
292
IDictionary connectionErrors = new Hashtable ( ) ;
270
293
IConnection conn = CreateConnection ( maxRedirects ,
271
294
connectionAttempts ,
272
295
connectionErrors ,
273
- endpoints ) ;
296
+ new AmqpTcpEndpoint [ ] { Endpoint } ) ;
274
297
if ( conn != null ) {
275
298
return conn ;
276
299
}
277
300
throw new BrokerUnreachableException ( connectionAttempts , connectionErrors ) ;
278
301
}
279
302
280
- ///<summary>Create a connection to the first available
281
- ///endpoint in the list provided. No broker-originated
282
- ///redirects are permitted.</summary>
283
- public virtual IConnection CreateConnection ( params AmqpTcpEndpoint [ ] endpoints )
303
+ ///<summary>Create a connection to the specified endpoint
304
+ ///No broker-originated redirects are permitted.</summary>
305
+ public virtual IConnection CreateConnection ( )
284
306
{
285
- return CreateConnection ( 0 , endpoints ) ;
286
- }
287
-
288
- ///<summary>Create a connection to the endpoint specified.</summary>
289
- ///<exception cref="ArgumentException"/>
290
- public IConnection CreateConnection ( IProtocol version ,
291
- string hostName ,
292
- int portNumber )
293
- {
294
- return CreateConnection ( new AmqpTcpEndpoint ( version ,
295
- hostName ,
296
- portNumber ,
297
- this . Ssl ) ) ;
298
- }
299
-
300
- ///<summary>Create a connection to the endpoint specified. The
301
- ///port used is the default for the protocol.</summary>
302
- ///<exception cref="ArgumentException"/>
303
- public IConnection CreateConnection ( IProtocol version , string hostName )
304
- {
305
- return CreateConnection ( new AmqpTcpEndpoint ( version , hostName ) ) ;
306
- }
307
-
308
- ///<summary>Create a connection to the endpoint specified.</summary>
309
- ///<remarks>
310
- /// Please see the class overview documentation for
311
- /// information about the Uri format in use.
312
- ///</remarks>
313
- ///<exception cref="ArgumentException"/>
314
- public IConnection CreateConnection ( IProtocol version , Uri uri )
315
- {
316
- return CreateConnection ( new AmqpTcpEndpoint ( version , uri ) ) ;
317
- }
318
-
319
- ///<summary>Create a connection to the endpoint specified,
320
- ///with the IProtocol from
321
- ///Protocols.FromEnvironment().</summary>
322
- ///<remarks>
323
- /// Please see the class overview documentation for
324
- /// information about the Uri format in use.
325
- ///</remarks>
326
- public IConnection CreateConnection ( Uri uri )
327
- {
328
- return CreateConnection ( new AmqpTcpEndpoint ( uri ) ) ;
329
- }
330
-
331
- ///<summary>Create a connection to the host (and optional
332
- ///port) specified, with the IProtocol from
333
- ///Protocols.FromEnvironment(). The format of the address
334
- ///string is the same as that accepted by
335
- ///AmqpTcpEndpoint.Parse().</summary>
336
- public IConnection CreateConnection ( string address ) {
337
- return CreateConnection ( AmqpTcpEndpoint . Parse ( Protocols . FromEnvironment ( ) , address ) ) ;
307
+ return CreateConnection ( 0 ) ;
338
308
}
339
309
}
340
310
}
0 commit comments