Exemplo n.º 1
0
        public static IConnectionFactory ConnectionFactoryFrom(IAmqpConnectionSettings settings)
        {
            var factory = new ConnectionFactory();

            switch (settings)
            {
            case AmqpConnectionUri connectionUri:
                factory.Uri = connectionUri.Uri;
                break;

            case AmqpConnectionDetails details:
            {
                if (details.Credentials.HasValue)
                {
                    factory.UserName = details.Credentials.Value.Username;
                    factory.Password = details.Credentials.Value.Password;
                }
                if (!string.IsNullOrEmpty(details.VirtualHost))
                {
                    factory.VirtualHost = details.VirtualHost;
                }
                if (details.Ssl != null)
                {
                    factory.Ssl = details.Ssl;
                }
                if (details.AutomaticRecoveryEnabled.HasValue)
                {
                    factory.AutomaticRecoveryEnabled = details.AutomaticRecoveryEnabled.Value;
                }
                if (details.RequestedHeartbeat.HasValue)
                {
                    factory.RequestedHeartbeat = new TimeSpan(details.RequestedHeartbeat.Value);
                }
                if (details.NetworkRecoveryInterval.HasValue)
                {
                    factory.NetworkRecoveryInterval = details.NetworkRecoveryInterval.Value;
                }
                if (details.TopologyRecoveryEnabled.HasValue)
                {
                    factory.TopologyRecoveryEnabled = details.TopologyRecoveryEnabled.Value;
                }
                if (details.ConnectionTimeout.HasValue)
                {
                    factory.ContinuationTimeout = details.ConnectionTimeout.Value;
                }
                if (details.HandshakeTimeout.HasValue)
                {
                    factory.HandshakeContinuationTimeout = details.HandshakeTimeout.Value;
                }
                break;
            }

            case DefaultAmqpConnection defaultConnection:
                //leave it be as is
                break;
            }
            return(factory);
        }
Exemplo n.º 2
0
 private NamedQueueSourceSettings(IAmqpConnectionSettings connectionSettings, string queue,
                                  IReadOnlyList <IDeclaration> declarations = null, bool noLocal = false, bool exclusive = false,
                                  string consumerTag = null,
                                  IReadOnlyDictionary <string, object> arguments = null)
 {
     ConnectionSettings = connectionSettings;
     Queue        = queue;
     Declarations = declarations ?? new List <IDeclaration>();
     NoLocal      = noLocal;
     Exclusive    = exclusive;
     ConsumerTag  = consumerTag ?? "default";
     Arguments    = arguments ?? new Dictionary <string, object>();
 }
Exemplo n.º 3
0
        public static IConnection NewConnection(IConnectionFactory factory, IAmqpConnectionSettings settings)
        {
            switch (settings)
            {
            case AmqpConnectionDetails details:
            {
                if (details.HostAndPortList.Count > 0)
                {
                    return(factory.CreateConnection(details.HostAndPortList
                                                    .Select(pair => new AmqpTcpEndpoint(pair.host, pair.port)).ToList()));
                }
                else
                {
                    throw new ArgumentException("You need to supply at least one host/port pair.");
                }
            }

            default:
                return(factory.CreateConnection());
            }
        }
Exemplo n.º 4
0
 public static NamedQueueSourceSettings Create(IAmqpConnectionSettings connectionSettings, string queue)
 {
     return(new NamedQueueSourceSettings(connectionSettings, queue));
 }
Exemplo n.º 5
0
 public override IConnection NewConnection(IConnectionFactory factory, IAmqpConnectionSettings settings) =>
 AmqpConnector.NewConnection(factory, settings);
Exemplo n.º 6
0
 public override IConnectionFactory ConnectionFactoryFrom(IAmqpConnectionSettings settings) =>
 AmqpConnector.ConnectionFactoryFrom(settings);
Exemplo n.º 7
0
 public override IConnectionFactory ConnectionFactoryFrom(IAmqpConnectionSettings settings)
 {
     return(AmqpConnector.ConnectionFactoryFrom(settings));
 }
Exemplo n.º 8
0
 public abstract IConnection NewConnection(IConnectionFactory factory, IAmqpConnectionSettings settings);
Exemplo n.º 9
0
 public abstract IConnectionFactory ConnectionFactoryFrom(IAmqpConnectionSettings settings);