/// <summary>
        /// Unsubscribes from the AMQP exchange subscription using the form's values.
        /// </summary>
        public void Unsubscribe()
        {
            // Validate args
            var isValid = true;

            var exchangeName = ExchangeName.options[ExchangeName.value].text;

            if (string.IsNullOrEmpty(exchangeName))
            {
                isValid           = false;
                AmqpConsole.Color = Color.red;
                AmqpConsole.WriteLine("* Exchange Name cannot be blank");
                AmqpConsole.Color = null;
            }

            // Don't continue if values are invald
            if (!isValid)
            {
                return;
            }

            var exchangeType = AmqpExchangeTypes.Direct;

            // Find this exchange and get its exchange type
            foreach (var exchange in exchanges)
            {
                if (exchange.Name == exchangeName)
                {
                    exchangeType = exchange.Type;
                    break;
                }
            }

            var routingKey = RoutingKey.text;

            // Ensure this subscription already exists
            var subs = exSubscriptions.ToArray();

            foreach (var sub in subs)
            {
                if (sub.ExchangeName == exchangeName && sub.ExchangeType == exchangeType && sub.RoutingKey == routingKey)
                {
                    AmqpClient.Unsubscribe(sub);
                    exSubscriptions.Remove(sub);
                    return;
                }
            }

            AmqpConsole.Color = new Color(1f, 0.5f, 0);
            AmqpConsole.WriteLineFormat("Subscription not found for exchange {0}:{1}", exchangeName, routingKey);
            AmqpConsole.Color = null;
        }
Beispiel #2
0
        public void UnsubscribeQueue()
        {
            Debug.Log("UnsubscribeQueue");
            var queueName = SubscribeQueueName.text;

            foreach (var sub in queueSubscriptions)
            {
                if (sub.QueueName == queueName)
                {
                    AmqpClient.Unsubscribe(sub);
                    AmqpConsole.Color = new Color(0f, 1f, 0);
                    AmqpConsole.WriteLineFormat("Unsubscribed for queue {0}", sub.QueueName);
                    AmqpConsole.Color = null;
                    return;
                }
            }

            AmqpConsole.Color = new Color(1f, 0f, 0);
            AmqpConsole.WriteLineFormat("NO Subscription exists for queue {0}", queueName);
            AmqpConsole.Color = null;
        }