|
36 | 36 | using System.Reflection; |
37 | 37 | using System.Security.Authentication; |
38 | 38 | using System.Text; |
| 39 | +using RabbitMQ.Client.client.impl; |
39 | 40 | using RabbitMQ.Client.Exceptions; |
40 | 41 | using RabbitMQ.Client.Framing.Impl; |
41 | 42 | using RabbitMQ.Client.Impl; |
@@ -199,7 +200,7 @@ public TimeSpan HandshakeContinuationTimeout |
199 | 200 | } |
200 | 201 |
|
201 | 202 | /// <summary> |
202 | | - /// Amount of time protocol operations (e.g. <code>queue.declare</code>) are allowed to take before |
| 203 | + /// Amount of time protocol operations (e.g. <code>queue.declare</code>) are allowed to take before |
203 | 204 | /// timing out. |
204 | 205 | /// </summary> |
205 | 206 | public TimeSpan ContinuationTimeout |
@@ -492,32 +493,47 @@ public IConnection CreateConnection(IList<AmqpTcpEndpoint> endpoints, string cli |
492 | 493 | /// </exception> |
493 | 494 | public IConnection CreateConnection(IEndpointResolver endpointResolver, string clientProvidedName) |
494 | 495 | { |
495 | | - IConnection conn; |
| 496 | + ConnectionConfig config = CreateConfig(clientProvidedName); |
496 | 497 | try |
497 | 498 | { |
498 | 499 | if (AutomaticRecoveryEnabled) |
499 | 500 | { |
500 | | - var autorecoveringConnection = new AutorecoveringConnection(this, clientProvidedName); |
501 | | - autorecoveringConnection.Init(endpointResolver); |
502 | | - conn = autorecoveringConnection; |
503 | | - } |
504 | | - else |
505 | | - { |
506 | | - conn = ((ProtocolBase)Protocols.AMQP_0_9_1).CreateConnection(this, endpointResolver.SelectOne(CreateFrameHandler), clientProvidedName); |
| 501 | + return new AutorecoveringConnection(config, endpointResolver); |
507 | 502 | } |
| 503 | + |
| 504 | + return new Connection(config, endpointResolver.SelectOne(CreateFrameHandler)); |
508 | 505 | } |
509 | 506 | catch (Exception e) |
510 | 507 | { |
511 | 508 | throw new BrokerUnreachableException(e); |
512 | 509 | } |
| 510 | + } |
513 | 511 |
|
514 | | - return conn; |
| 512 | + private ConnectionConfig CreateConfig(string clientProvidedName) |
| 513 | + { |
| 514 | + return new ConnectionConfig( |
| 515 | + VirtualHost, |
| 516 | + UserName, |
| 517 | + Password, |
| 518 | + AuthMechanisms, |
| 519 | + ClientProperties, |
| 520 | + clientProvidedName, |
| 521 | + RequestedChannelMax, |
| 522 | + RequestedFrameMax, |
| 523 | + TopologyRecoveryEnabled, |
| 524 | + NetworkRecoveryInterval, |
| 525 | + RequestedHeartbeat, |
| 526 | + ContinuationTimeout, |
| 527 | + HandshakeContinuationTimeout, |
| 528 | + RequestedConnectionTimeout, |
| 529 | + DispatchConsumersAsync, |
| 530 | + ConsumerDispatchConcurrency, |
| 531 | + CreateFrameHandler); |
515 | 532 | } |
516 | 533 |
|
517 | 534 | internal IFrameHandler CreateFrameHandler(AmqpTcpEndpoint endpoint) |
518 | 535 | { |
519 | | - IFrameHandler fh = Protocols.DefaultProtocol.CreateFrameHandler(endpoint, SocketFactory, |
520 | | - RequestedConnectionTimeout, SocketReadTimeout, SocketWriteTimeout); |
| 536 | + IFrameHandler fh = new SocketFrameHandler(endpoint, SocketFactory, RequestedConnectionTimeout, SocketReadTimeout, SocketWriteTimeout); |
521 | 537 | return ConfigureFrameHandler(fh); |
522 | 538 | } |
523 | 539 |
|
|
0 commit comments