protected ConnectionListener(
            Uri addressUri,
            AmqpSettings amqpSettings,
            AmqpConnectionSettings connectionSettings)
        {
            amqpSettings.ValidateListenerSettings();
            this.listenAddress = addressUri;
            this.amqpSettings = amqpSettings;
            this.connectionSettings = connectionSettings;
            this.onAcceptTransport = this.OnAcceptTransport;

            TcpTransportSettings tcpSettings = new TcpTransportSettings();
            tcpSettings.SetEndPoint(addressUri.Host, addressUri.Port, true);
            TransportListener tpListener = null;
            if (addressUri.Scheme.Equals(AmqpConstants.SchemeAmqps, StringComparison.OrdinalIgnoreCase))
            {
                TlsTransportProvider tlsProvider = this.amqpSettings.GetTransportProvider<TlsTransportProvider>();
                if (tlsProvider == null)
                {
                    throw Fx.Exception.ArgumentNull("TlsSecurityProvider");
                }

                Fx.Assert(tlsProvider.Settings.Certificate != null, "Must have a valid certificate.");
                TlsTransportSettings tlsSettings = new TlsTransportSettings(tcpSettings, false);
                tlsSettings.Certificate = tlsProvider.Settings.Certificate;
                tpListener = tlsSettings.CreateListener();
            }
            else
            {
                tpListener = tcpSettings.CreateListener();
            }

            this.transportListener = new AmqpTransportListener(new TransportListener[] { tpListener }, this.amqpSettings);
            this.onConnectionOpenComplete = new AsyncCallback(this.OnConnectionOpenComplete);
        }
 public static ConnectionListener CreateSharedListener(
     Uri addressUri,
     AmqpSettings amqpSettings,
     AmqpConnectionSettings connectionSettings)
 {
     return new SharedConnectionListener(addressUri, amqpSettings, connectionSettings);
 }
Beispiel #3
0
 private void Negotiate(Open open)
 {
     base.Settings.RemoteContainerId = open.ContainerId;
     base.Settings.RemoteHostName    = open.HostName;
     base.Settings.ChannelMax        = new ushort?(Math.Min(base.Settings.ChannelMax(), open.ChannelMax()));
     base.FindMutualCapabilites(base.Settings.DesiredCapabilities, open.OfferedCapabilities);
     if (open.MaxFrameSize.HasValue)
     {
         AmqpConnectionSettings settings = base.Settings;
         uint value        = base.Settings.MaxFrameSize.Value;
         uint?maxFrameSize = open.MaxFrameSize;
         settings.MaxFrameSize = new uint?(Math.Min(value, maxFrameSize.Value));
     }
 }
 public AmqpTransportManager(Uri listenUri, AmqpSettings amqpSettings, TimeSpan openTimeout)
 {
     this.ListenUri    = new Uri(listenUri.GetLeftPart(UriPartial.Authority));
     this.addressTable = new UriPrefixTable <AmqpChannelListenerBase>(false);
     this.OpenTimeout  = openTimeout;
     this.amqpSettings = amqpSettings.Clone();
     this.amqpSettings.RuntimeProvider = this;
     this.amqpConnectionSettings       = new AmqpConnectionSettings()
     {
         ContainerId = Guid.NewGuid().ToString("N")
     };
     this.id = string.Concat(base.GetType().Name, this.GetHashCode());
     MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteAmqpLogOperation(this, TraceOperation.Create, this.ListenUri));
 }
Beispiel #5
0
                private void OnTransportCallback(TransportAsyncCallbackArgs args)
                {
                    if (args.Exception != null)
                    {
                        base.Complete(args.CompletedSynchronously, args.Exception);
                        return;
                    }
                    AmqpConnectionSettings amqpConnectionSetting = new AmqpConnectionSettings()
                    {
                        ContainerId = Guid.NewGuid().ToString("N")
                    };

                    this.AmqpConnection = new AmqpConnection(args.Transport, this.amqpSettings, amqpConnectionSetting);
                    base.Complete(args.CompletedSynchronously);
                }
Beispiel #6
0
        public AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) :
            base(transport, connectionSettings)
        {
            if (amqpSettings == null)
            {
                throw new ArgumentNullException("amqpSettings");
            }

            this.initialHeader = protocolHeader;
            this.isInitiator = isInitiator;
            this.amqpSettings = amqpSettings;
            this.frameDecoder = new FrameDecoder((int)this.Settings.MaxFrameSize);
            this.sessionsByLocalHandle = new HandleTable<AmqpSession>(this.Settings.ChannelMax.Value);
            this.sessionsByRemoteHandle = new HandleTable<AmqpSession>(this.Settings.ChannelMax.Value);
            this.SessionFactory = this;
        }
Beispiel #7
0
        public AmqpConnectionBase(TransportBase transport, AmqpConnectionSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            this.settings = settings;

            Fx.Assert(transport != null, "transport must not be null.");
            this.principal = transport.Principal;
            this.asyncIO   = new AsyncIO(
                AmqpConstants.AsyncBufferSize,
                transport,
                new Action <ByteBuffer>(this.OnReceiveBuffer),
                this.OnAsyncIoFaulted);
            this.bufferHandler = new SerializedWorker <ByteBuffer>(this.OnReceiveFrameBuffer, null, false);
        }
        public AmqpConnectionBase(TransportBase transport, AmqpConnectionSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            this.settings = settings;

            Fx.Assert(transport != null, "transport must not be null.");
            this.principal = transport.Principal;
            this.asyncIO = new AsyncIO(
                AmqpConstants.AsyncBufferSize,
                transport,
                new Action<ByteBuffer>(this.OnReceiveBuffer),
                this.OnAsyncIoFaulted);
            this.bufferHandler = new SerializedWorker<ByteBuffer>(this.OnReceiveFrameBuffer, null, false);
        }
        public AmqpConnectionSettings Clone()
        {
            AmqpConnectionSettings newSettings = new AmqpConnectionSettings();

            newSettings.ContainerId = this.ContainerId;
            newSettings.HostName = this.HostName;
            newSettings.MaxFrameSize = this.MaxFrameSize;
            newSettings.ChannelMax = this.ChannelMax;
            newSettings.IdleTimeOut = this.IdleTimeOut;
            newSettings.OutgoingLocales = this.OutgoingLocales;
            newSettings.IncomingLocales = this.IncomingLocales;
            newSettings.Properties = this.Properties;
            newSettings.OfferedCapabilities = this.OfferedCapabilities;
            newSettings.DesiredCapabilities = this.DesiredCapabilities;
            newSettings.Properties = this.Properties;

            return newSettings;
        }
Beispiel #10
0
        public AmqpConnectionSettings Clone()
        {
            AmqpConnectionSettings newSettings = new AmqpConnectionSettings();

            newSettings.ContainerId         = this.ContainerId;
            newSettings.HostName            = this.HostName;
            newSettings.MaxFrameSize        = this.MaxFrameSize;
            newSettings.ChannelMax          = this.ChannelMax;
            newSettings.IdleTimeOut         = this.IdleTimeOut;
            newSettings.OutgoingLocales     = this.OutgoingLocales;
            newSettings.IncomingLocales     = this.IncomingLocales;
            newSettings.Properties          = this.Properties;
            newSettings.OfferedCapabilities = this.OfferedCapabilities;
            newSettings.DesiredCapabilities = this.DesiredCapabilities;
            newSettings.Properties          = this.Properties;

            return(newSettings);
        }
        public AmqpConnectionSettings Clone()
        {
            AmqpConnectionSettings amqpConnectionSetting = new AmqpConnectionSettings()
            {
                ContainerId         = base.ContainerId,
                HostName            = base.HostName,
                MaxFrameSize        = base.MaxFrameSize,
                ChannelMax          = base.ChannelMax,
                IdleTimeOut         = base.IdleTimeOut,
                OutgoingLocales     = base.OutgoingLocales,
                IncomingLocales     = base.IncomingLocales,
                Properties          = base.Properties,
                OfferedCapabilities = base.OfferedCapabilities,
                DesiredCapabilities = base.DesiredCapabilities
            };

            amqpConnectionSetting.Properties            = base.Properties;
            amqpConnectionSetting.SendBufferSize        = this.SendBufferSize;
            amqpConnectionSetting.ReceiveBufferSize     = this.ReceiveBufferSize;
            amqpConnectionSetting.IgnoreMissingSessions = this.IgnoreMissingSessions;
            return(amqpConnectionSetting);
        }
        protected ConnectionListener(
            Uri addressUri,
            AmqpSettings amqpSettings,
            AmqpConnectionSettings connectionSettings)
        {
            amqpSettings.ValidateListenerSettings();
            this.listenAddress      = addressUri;
            this.amqpSettings       = amqpSettings;
            this.connectionSettings = connectionSettings;
            this.onAcceptTransport  = this.OnAcceptTransport;

            TcpTransportSettings tcpSettings = new TcpTransportSettings();

            tcpSettings.SetEndPoint(addressUri.Host, addressUri.Port, true);
            TransportListener tpListener = null;

            if (addressUri.Scheme.Equals(AmqpConstants.SchemeAmqps, StringComparison.OrdinalIgnoreCase))
            {
                TlsTransportProvider tlsProvider = this.amqpSettings.GetTransportProvider <TlsTransportProvider>();
                if (tlsProvider == null)
                {
                    throw Fx.Exception.ArgumentNull("TlsSecurityProvider");
                }

                Fx.Assert(tlsProvider.Settings.Certificate != null, "Must have a valid certificate.");
                TlsTransportSettings tlsSettings = new TlsTransportSettings(tcpSettings, false);
                tlsSettings.Certificate = tlsProvider.Settings.Certificate;
                tpListener = tlsSettings.CreateListener();
            }
            else
            {
                tpListener = tcpSettings.CreateListener();
            }

            this.transportListener        = new AmqpTransportListener(new TransportListener[] { tpListener }, this.amqpSettings);
            this.onConnectionOpenComplete = new AsyncCallback(this.OnConnectionOpenComplete);
        }
        private void OnAcceptTransport(TransportAsyncCallbackArgs args)
        {
            AmqpConnectionSettings amqpConnectionSetting = this.amqpConnectionSettings;
            AmqpConnection         amqpConnection        = null;

            try
            {
                amqpConnection = this.CreateConnection(args.Transport, (ProtocolHeader)args.UserToken, false, this.amqpSettings, amqpConnectionSetting);
                (new AmqpTransportManager.ConnectionHandler(amqpConnection, this.OpenTimeout)).Start();
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                Fx.Exception.TraceHandled(exception, "AmqpTransportManager.OnAcceptTransport", null);
                if (amqpConnection != null)
                {
                    amqpConnection.SafeClose(exception);
                }
            }
        }
Beispiel #14
0
 public AmqpConnection(TransportBase transport, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) :
     this(transport, amqpSettings.GetDefaultHeader(), true, amqpSettings, connectionSettings)
 {
 }
Beispiel #15
0
        public AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) :
            base(transport, connectionSettings)
        {
            if (amqpSettings == null)
            {
                throw new ArgumentNullException("amqpSettings");
            }

            this.initialHeader          = protocolHeader;
            this.isInitiator            = isInitiator;
            this.amqpSettings           = amqpSettings;
            this.frameDecoder           = new FrameDecoder((int)this.Settings.MaxFrameSize);
            this.sessionsByLocalHandle  = new HandleTable <AmqpSession>(this.Settings.ChannelMax.Value);
            this.sessionsByRemoteHandle = new HandleTable <AmqpSession>(this.Settings.ChannelMax.Value);
            this.SessionFactory         = this;
        }
        public AmqpConnection CreateConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings)
        {
            AmqpConnection amqpConnection = new AmqpConnection(transport, protocolHeader, isInitiator, amqpSettings, connectionSettings)
            {
                SessionFactory = this
            };

            MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteAmqpLogOperation(this, TraceOperation.Connect, amqpConnection));
            return(amqpConnection);
        }
Beispiel #17
0
 AmqpConnection IConnectionFactory.CreateConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
 internal AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, Microsoft.ServiceBus.Messaging.Amqp.AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) : this(transport, protocolHeader, true, amqpSettings, connectionSettings)
 {
 }
Beispiel #19
0
 public SharedConnectionListener(
     Uri addressUri,
     AmqpSettings amqpSettings,
     AmqpConnectionSettings connectionSettings)
     : base(addressUri, amqpSettings, connectionSettings)
 {
     this.connectionHandlers = new ConcurrentDictionary<string, IConnectionHandler>(StringComparer.OrdinalIgnoreCase);
     this.connectionOpenCallback = this.OnConnectionOpen;
 }
Beispiel #20
0
 public ExclusiveConnectionListener(
     Uri addressUri,
     AmqpSettings amqpSettings,
     AmqpConnectionSettings connectionSettings,
     IConnectionHandler connectionHandler)
     : base(addressUri, amqpSettings, connectionSettings)
 {
     Fx.Assert(connectionHandler != null, "Connection handler cannot be null.");
     this.connectionHandler = connectionHandler;
 }
Beispiel #21
0
 public AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) :
     this(transport, protocolHeader, true, amqpSettings, connectionSettings)
 {
 }
Beispiel #22
0
 public AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) :
     this(transport, protocolHeader, true, amqpSettings, connectionSettings)
 {
 }
        public AmqpConnection CreateConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings)
        {
            if (this.amqpSettings.RequireSecureTransport && !transport.IsSecure)
            {
                throw new AmqpException(AmqpError.NotAllowed, SR.AmqpTransportNotSecure);
            }

            AmqpConnection connection = new AmqpConnection(transport, protocolHeader, isInitiator, amqpSettings, connectionSettings);

            Utils.Trace(TraceLevel.Info, "{0}: Created {1}", this, connection);
            return(connection);
        }
Beispiel #24
0
 public static ConnectionListener CreateExclusiveListener(
     Uri addressUri,
     AmqpSettings amqpSettings,
     AmqpConnectionSettings connectionSettings,
     IConnectionHandler connectionHandler)
 {
     return new ExclusiveConnectionListener(addressUri, amqpSettings, connectionSettings, connectionHandler);
 }
Beispiel #25
0
        public AmqpConnection CreateConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings)
        {
            if (this.amqpSettings.RequireSecureTransport && !transport.IsSecure)
            {
                throw new AmqpException(AmqpError.NotAllowed, SR.AmqpTransportNotSecure);
            }

            AmqpConnection connection = new AmqpConnection(transport, protocolHeader, isInitiator, amqpSettings, connectionSettings);
            Utils.Trace(TraceLevel.Info, "{0}: Created {1}", this, connection);
            return connection;
        }
Beispiel #26
0
 internal AmqpConnection(TransportBase transport, Microsoft.ServiceBus.Messaging.Amqp.AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) : this(transport, amqpSettings.GetDefaultHeader(), true, amqpSettings, connectionSettings)
 {
 }
Beispiel #27
0
 AmqpConnection IConnectionFactory.CreateConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings)
 {
     throw new NotImplementedException();
 }
Beispiel #28
0
 internal AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, Microsoft.ServiceBus.Messaging.Amqp.AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) : base("connection", transport, connectionSettings, isInitiator)
 {
     if (amqpSettings == null)
     {
         throw new ArgumentNullException("amqpSettings");
     }
     this.initialHeader          = protocolHeader;
     this.isInitiator            = isInitiator;
     this.amqpSettings           = amqpSettings;
     this.sessionsByLocalHandle  = new HandleTable <AmqpSession>(base.Settings.ChannelMax.Value);
     this.sessionsByRemoteHandle = new HandleTable <AmqpSession>(base.Settings.ChannelMax.Value);
     this.SessionFactory         = this;
 }
Beispiel #29
0
 public AmqpConnection(TransportBase transport, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) :
     this(transport, amqpSettings.GetDefaultHeader(), true, amqpSettings, connectionSettings)
 {
 }