示例#1
0
        /// <summary>
        /// A default message received handler useful for debugging.
        /// </summary>
        /// <param name="subscription">The subscription the message was received on.</param>
        /// <param name="message">The message that was received.</param>
        public void UnityEventDebugExhangeMessageHandler(AmqpExchangeSubscription subscription, IAmqpReceivedMessage message)
        {
            // Decode as text
            var payload = System.Text.Encoding.UTF8.GetString(message.Body);

            AmqpConsole.Color = new Color(1f, 0.5f, 0);
            AmqpClient.Log("Message received on {0}: {1}", subscription.ExchangeName + (!string.IsNullOrEmpty(message.RoutingKey) ? ":" + message.RoutingKey : ""), payload);
            AmqpConsole.Color = null;

            MessageListController.AddMessage(subscription, message);
        }
示例#2
0
        public void GetAllQueue()
        {
            Debug.Log("GetAllQueue");

            AmqpQueue[] queues = AmqpClient.GetQueues();

            foreach (var q in queues)
            {
                AmqpClient.Log(q.Name);
            }
        }
示例#3
0
        /// <summary>
        /// A default message received handler useful for debugging.
        /// </summary>
        /// <param name="subscription">The subscription the message was received on.</param>
        /// <param name="message">The message that was received.</param>
        public void UnityEventDebugQueueMessageHandler(AmqpQueueSubscription subscription, IAmqpReceivedMessage message)
        {
            // Decode as text
            queueMessages.Enqueue(message);
            var payload = System.Text.Encoding.UTF8.GetString(message.Body);

            AmqpConsole.Color = new Color(1f, 0.5f, 0);
            AmqpClient.Log("Message received on {0}: {1}", subscription.QueueName, payload);
            //AmqpClient.Log("ReplyTo: " + message.Properties.ReplyTo);
            AmqpConsole.Color = null;

            MessageListController.AddMessage(subscription, message);
        }
示例#4
0
        public void MultiAckMessage()
        {
            try
            {
                AmqpClient.BasicAck(message.DeliveryTag, true);

                var payload = System.Text.Encoding.UTF8.GetString(message.Body);
                AmqpConsole.Color = new Color(1f, 0.5f, 0);
                AmqpClient.Log("This message (and all previous unacknowledged ones) were acknowledged: " + payload);
                AmqpConsole.Color = null;
            }
            catch (Exception ex)
            {
                AmqpConsole.Color = new Color(1f, 0.5f, 0);
                AmqpClient.Log("ERROR: " + ex.Message);
                AmqpConsole.Color = null;
            }
            Background.color = new Color32(45, 210, 39, 81);
        }
示例#5
0
        public void BasicAck()
        {
            if (queueMessages.Count > 0)
            {
                var msg = queueMessages.Dequeue();

                try
                {
                    AmqpClient.BasicAck(msg.DeliveryTag, false);

                    var payload = System.Text.Encoding.UTF8.GetString(msg.Body);
                    AmqpConsole.Color = new Color(1f, 0.5f, 0);
                    AmqpClient.Log("Message acknowledged: " + payload);
                    AmqpConsole.Color = null;
                }
                catch (Exception ex)
                {
                    AmqpConsole.Color = new Color(1f, 0.5f, 0);
                    AmqpClient.Log("ERROR: " + ex.Message);
                    AmqpConsole.Color = null;
                }
            }
        }