Пример #1
0
        public void AddSubscribeChannel(Uri networkAddress, string address, AuthenticationMode authMode = AuthenticationMode.Auto, X509Certificate certificate = null)
        {
            if (!IsOpen)
            {
                throw new Exception("The Endpoint must be open before adding or removing channels.");
            }
            string key = networkAddress.ToString();

            AmqpConnection channel = null;

            if (channels.ContainsKey(key))
            {
                channel = channels[key];
            }
            else
            {
                channel = new AmqpConnection(networkAddress, this, authMode, certificate);
                channel.OnCFXMessageReceived  += Channel_OnCFXMessageReceived;
                channel.OnValidateCertificate += Channel_OnValidateCertificate;
                channels[key] = channel;
            }

            if (channel != null)
            {
                channel.AddSubscribeChannel(address);
            }
        }
Пример #2
0
        public void CloseSubscribeChannel(Uri networkAddress, string address)
        {
            if (!IsOpen)
            {
                throw new Exception("The Endpoint must be open before adding or removing channels.");
            }
            string key = networkAddress.ToString();

            AmqpConnection channel = null;

            if (channels.ContainsKey(key))
            {
                channel = channels[key];
                channel.RemoveChannel(address);
            }
            else
            {
                throw new ArgumentException("The specified channel does not exist.");
            }
        }
Пример #3
0
        public bool TestChannel(Uri channelUri, AuthenticationMode authMode, out Exception error)
        {
            bool result = false;

            error = null;

            try
            {
                CFXHandle = Guid.NewGuid().ToString();
                AmqpConnection conn = new AmqpConnection(channelUri, this, authMode);
                conn.OpenConnection();
                conn.Close();
                result = true;
            }
            catch (Exception ex)
            {
                error = ex;
                Debug.WriteLine(ex.Message);
            }

            return(result);
        }
Пример #4
0
        /// <summary>
        /// Closes the specified publish channel (that was opened previously via a call to AddPublishChannel.
        /// </summary>
        /// <param name="networkAddress">The network address of the channel to be closed.</param>
        /// <param name="address">The AMQP target address of the channel to be closed.</param>
        public void ClosePublishChannel(Uri networkAddress, string address)
        {
            if (!IsOpen)
            {
                throw new Exception("The Endpoint must be open before adding or removing channels.");
            }
            string key = networkAddress.ToString();

            AmqpConnection channel = null;

            if (channels.ContainsKey(key))
            {
                while (!channels.TryRemove(key, out channel))
                {
                    Task.Yield();
                }
                channel.RemoveChannel(address);
            }
            else
            {
                throw new ArgumentException("The specified channel does not exist.");
            }
        }
Пример #5
0
 public AmqpSenderLink(Uri uri, string address, string sourceHandle, AmqpConnection conn) : base(address)
 {
     Queue      = new DurableQueue(GetLinkFileName(uri, address, sourceHandle));
     LinkType   = LinkType.Sender;
     Connection = conn;
 }