public TestAmqpBroker(IList<Uri> endpoints, string userInfo, string certValue, string[] queues)
        {
            this.txnManager = new TxnManager();
            this.queues = new Dictionary<string, TestQueue>();
            if (queues != null)
            {
                foreach (string q in queues)
                {
                    this.queues.Add(q, new TestQueue(this));
                }
            }
            else
            {
                this.implicitQueue = true;
            }

            this.certificate = certValue == null ? null : GetCertificate(certValue);

            string containerId = "TestAmqpBroker:" + Guid.NewGuid().ToString().Substring(0, 8);
            this.listeners = new ConnectionListener[endpoints.Count];
            for (int i = 0; i < endpoints.Count; i++)
            {
                this.listeners[i] = new ConnectionListener(endpoints[i], userInfo, this);
                this.listeners[i].AMQP.MaxSessionsPerConnection = 1000;
                this.listeners[i].AMQP.ContainerId = containerId;
                this.listeners[i].AMQP.IdleTimeout = 4 * 60 * 1000;
                this.listeners[i].AMQP.MaxFrameSize = 64 * 1024;
            }
        }
        public TestAmqpBroker(IList <Uri> endpoints, string userInfo, string certValue, string[] queues)
        {
            this.txnManager = new TxnManager();
            this.queues     = new Dictionary <string, TestQueue>();
            if (queues != null)
            {
                foreach (string q in queues)
                {
                    this.queues.Add(q, new TestQueue(this));
                }
            }
            else
            {
                this.implicitQueue = true;
            }

            this.certificate = certValue == null ? null : GetCertificate(certValue);

            string containerId = "TestAmqpBroker:" + Guid.NewGuid().ToString().Substring(0, 8);

            this.listeners = new ConnectionListener[endpoints.Count];
            for (int i = 0; i < endpoints.Count; i++)
            {
                this.listeners[i] = new ConnectionListener(endpoints[i], userInfo, this);
                this.listeners[i].AMQP.MaxSessionsPerConnection = 1000;
                this.listeners[i].AMQP.ContainerId  = containerId;
                this.listeners[i].AMQP.IdleTimeout  = 4 * 60 * 1000;
                this.listeners[i].AMQP.MaxFrameSize = 64 * 1024;
            }
        }
Example #3
0
        public TestAmqpBroker(IList <string> endpoints, string userInfo, string certValue, string[] queues)
        {
            this.customTransports = new Dictionary <string, TransportProvider>(StringComparer.OrdinalIgnoreCase);
            this.txnManager       = new TxnManager();
            this.queues           = new Dictionary <string, TestQueue>();
            if (queues != null)
            {
                foreach (string q in queues)
                {
                    this.queues.Add(q, new TestQueue(this));
                }
            }
            else
            {
                this.implicitQueue = true;
            }

            this.certificate = certValue == null ? null : GetCertificate(certValue);

            string containerId = "TestAmqpBroker:" + Guid.NewGuid().ToString().Substring(0, 8);

            this.listeners = new ConnectionListener[endpoints.Count];
            for (int i = 0; i < endpoints.Count; i++)
            {
                this.listeners[i] = new ConnectionListener(endpoints[i], this);
                this.listeners[i].AMQP.MaxSessionsPerConnection = 1000;
                this.listeners[i].AMQP.ContainerId  = containerId;
                this.listeners[i].AMQP.IdleTimeout  = 4 * 60 * 1000;
                this.listeners[i].AMQP.MaxFrameSize = 64 * 1024;
                if (userInfo != null)
                {
                    string[] a = userInfo.Split(':');
                    this.listeners[i].SASL.EnablePlainMechanism(
                        Uri.UnescapeDataString(a[0]),
                        a.Length == 1 ? string.Empty : Uri.UnescapeDataString(a[1]));
                }
                else
                {
                    this.listeners[i].SASL.EnableAnonymousMechanism = true;
                }
            }
        }
Example #4
0
 public TestAmqpBroker(IList <string> endpoints, string userInfo, string sslValue, string[] queues)
 {
     this.endpoints    = endpoints;
     this.userInfo     = userInfo;
     this.sslValue     = sslValue;
     this.containerId  = "TestAmqpBroker-P" + Process.GetCurrentProcess().Id;
     this.maxFrameSize = 64 * 1024;
     this.txnManager   = new TxnManager();
     this.connections  = new Dictionary <SequenceNumber, AmqpConnection>();
     this.queues       = new Dictionary <string, TestQueue>();
     if (queues != null)
     {
         foreach (string q in queues)
         {
             this.queues.Add(q, new TestQueue(this));
         }
     }
     else
     {
         this.implicitQueue = true;
     }
 }
Example #5
0
        public TestAmqpBroker(IList<string> endpoints, string userInfo, string certValue, string[] queues)
        {
            this.customTransports = new Dictionary<string, TransportProvider>(StringComparer.OrdinalIgnoreCase);
            this.txnManager = new TxnManager();
            this.queues = new Dictionary<string, TestQueue>();
            if (queues != null)
            {
                foreach (string q in queues)
                {
                    this.queues.Add(q, new TestQueue(this));
                }
            }
            else
            {
                this.implicitQueue = true;
            }

            this.certificate = certValue == null ? null : GetCertificate(certValue);

            string containerId = "TestAmqpBroker:" + Guid.NewGuid().ToString().Substring(0, 8);
            this.listeners = new ConnectionListener[endpoints.Count];
            for (int i = 0; i < endpoints.Count; i++)
            {
                this.listeners[i] = new ConnectionListener(endpoints[i], this);
                this.listeners[i].AMQP.MaxSessionsPerConnection = 1000;
                this.listeners[i].AMQP.ContainerId = containerId;
                this.listeners[i].AMQP.IdleTimeout = 4 * 60 * 1000;
                this.listeners[i].AMQP.MaxFrameSize = 64 * 1024;
                if (userInfo != null)
                {
                    string[] a = userInfo.Split(':');
                    this.listeners[i].SASL.EnablePlainMechanism(
                        Uri.UnescapeDataString(a[0]),
                        a.Length == 1 ? string.Empty : Uri.UnescapeDataString(a[1]));
                }
            }
        }
        public TestAmqpBroker(IList <Uri> endpoints, string userInfo, string certValue, string[] queues)
        {
            this.txnManager = new TxnManager();
            this.queues     = new Dictionary <string, TestQueue>();
            if (queues != null)
            {
                foreach (string q in queues)
                {
                    this.queues.Add(q, new TestQueue(this));
                }
            }
            else
            {
                this.implicitQueue = true;
            }

            this.certificate = certValue == null ? null : GetCertificate(certValue);

            this.listeners = new ConnectionListener[endpoints.Count];
            for (int i = 0; i < endpoints.Count; i++)
            {
                this.listeners[i] = new ConnectionListener(endpoints[i], userInfo, this);
            }
        }
Example #7
0
        public TestAmqpBroker(IList <string> endpoints, string userInfo, string sslValue, string[] queues)
        {
            this.containerId  = "TestAmqpBroker-P" + Process.GetCurrentProcess().Id;
            this.maxFrameSize = 64 * 1024;
            this.txnManager   = new TxnManager();
            this.connections  = new Dictionary <SequenceNumber, AmqpConnection>();
            this.queues       = new Dictionary <string, TestQueue>();
            if (queues != null)
            {
                foreach (string q in queues)
                {
                    this.queues.Add(q, new TestQueue(this));
                }
            }
            else
            {
                this.implicitQueue = true;
            }

            // create and initialize AmqpSettings
            AmqpSettings     settings    = new AmqpSettings();
            X509Certificate2 certificate = sslValue == null ? null : GetCertificate(sslValue);

            settings.RuntimeProvider = this;

            SaslHandler saslHandler;

            if (userInfo != null)
            {
                string[] creds     = userInfo.Split(':');
                string   usernanme = Uri.UnescapeDataString(creds[0]);
                string   password  = creds.Length == 1 ? string.Empty : Uri.UnescapeDataString(creds[1]);
                saslHandler = new SaslPlainHandler(new TestPlainAuthenticator(userInfo, password));
            }
            else
            {
                saslHandler = new SaslAnonymousHandler();
            }

            SaslTransportProvider saslProvider = new SaslTransportProvider();

            saslProvider.AddHandler(saslHandler);
            saslProvider.Versions.Add(new AmqpVersion(1, 0, 0));
            settings.TransportProviders.Add(saslProvider);

            AmqpTransportProvider amqpProvider = new AmqpTransportProvider();

            amqpProvider.Versions.Add(new AmqpVersion(1, 0, 0));
            settings.TransportProviders.Add(amqpProvider);

            // create and initialize transport listeners
            TransportListener[] listeners = new TransportListener[endpoints.Count];
            for (int i = 0; i < endpoints.Count; i++)
            {
                Uri addressUri = new Uri(endpoints[i]);

                if (addressUri.Scheme.Equals(AmqpConstants.SchemeAmqps, StringComparison.OrdinalIgnoreCase))
                {
                    if (certificate == null)
                    {
                        throw new InvalidOperationException("/cert option was not set when amqps address is specified.");
                    }

                    TcpTransportSettings tcpSettings = new TcpTransportSettings()
                    {
                        Host = addressUri.Host, Port = addressUri.Port
                    };
                    TlsTransportSettings tlsSettings = new TlsTransportSettings(tcpSettings)
                    {
                        Certificate = certificate, IsInitiator = false
                    };
                    listeners[i] = tlsSettings.CreateListener();
                }
                else if (addressUri.Scheme.Equals(AmqpConstants.SchemeAmqp, StringComparison.OrdinalIgnoreCase))
                {
                    TcpTransportSettings tcpSettings = new TcpTransportSettings()
                    {
                        Host = addressUri.Host, Port = addressUri.Port
                    };
                    listeners[i] = tcpSettings.CreateListener();
                }
#if !NETSTANDARD
                else if (addressUri.Scheme.Equals("ws", StringComparison.OrdinalIgnoreCase))
                {
                    WebSocketTransportSettings wsSettings = new WebSocketTransportSettings()
                    {
                        Uri = addressUri
                    };
                    listeners[i] = wsSettings.CreateListener();
                }
#endif
                else
                {
                    throw new NotSupportedException(addressUri.Scheme);
                }
            }

            this.transportListener = new AmqpTransportListener(listeners, settings);
            this.settings          = settings;
        }
Example #8
0
        public TestAmqpBroker(IList<string> endpoints, string userInfo, string sslValue, string[] queues)
        {
            this.containerId = "TestAmqpBroker-P" + Process.GetCurrentProcess().Id;
            this.maxFrameSize = 64 * 1024;
            this.txnManager = new TxnManager();
            this.connections = new Dictionary<SequenceNumber, AmqpConnection>();
            this.queues = new Dictionary<string, TestQueue>();
            if (queues != null)
            {
                foreach (string q in queues)
                {
                    this.queues.Add(q, new TestQueue(this));
                }
            }
            else
            {
                this.implicitQueue = true;
            }

            // create and initialize AmqpSettings
            AmqpSettings settings = new AmqpSettings();
            X509Certificate2 certificate = sslValue == null ? null : GetCertificate(sslValue);
            settings.RuntimeProvider = this;

            SaslHandler saslHandler;
            if (userInfo != null)
            {
                string[] creds = userInfo.Split(':');
                string usernanme = Uri.UnescapeDataString(creds[0]);
                string password = creds.Length == 1 ? string.Empty : Uri.UnescapeDataString(creds[1]);
                saslHandler = new SaslPlainHandler(new TestPlainAuthenticator(userInfo, password));
            }
            else
            {
                saslHandler = new SaslAnonymousHandler();
            }

            SaslTransportProvider saslProvider = new SaslTransportProvider();
            saslProvider.AddHandler(saslHandler);
            saslProvider.Versions.Add(new AmqpVersion(1, 0, 0));
            settings.TransportProviders.Add(saslProvider);

            AmqpTransportProvider amqpProvider = new AmqpTransportProvider();
            amqpProvider.Versions.Add(new AmqpVersion(1, 0, 0));
            settings.TransportProviders.Add(amqpProvider);

            // create and initialize transport listeners
            TransportListener[] listeners = new TransportListener[endpoints.Count];
            for (int i = 0; i < endpoints.Count; i++)
            {
                Uri addressUri = new Uri(endpoints[i]);

                TcpTransportSettings tcpSettings = new TcpTransportSettings() { Host = addressUri.Host, Port = addressUri.Port };
                if (addressUri.Scheme.Equals(AmqpConstants.SchemeAmqps, StringComparison.OrdinalIgnoreCase))
                {
                    if (certificate == null)
                    {
                        throw new InvalidOperationException("/cert option was not set when amqps address is specified.");
                    }

                    TlsTransportSettings tlsSettings = new TlsTransportSettings(tcpSettings) { Certificate = certificate, IsInitiator = false };
                    listeners[i] = tlsSettings.CreateListener();
                }
                else
                {
                    listeners[i] = tcpSettings.CreateListener();
                }
            }

            this.transportListener = new AmqpTransportListener(listeners, settings);
            this.settings = settings;
        }