Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void Receive(object sender, BasicDeliverEventArgs e)
        {
            var body = new MessageBody();

            try
            {
                var content = MqConnection.Utf8.GetString(e.Body);
                body.Content      = content;
                body.Consumer     = (EventingBasicConsumer)sender;
                body.BasicDeliver = e;
            }
            catch (Exception ex)
            {
                body.Content = $"订阅-出错{ex.Message}";
                body.Success = false;
                body.Code    = 500;
            }
            OnReceived?.Invoke(body);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 接收消息
 /// </summary>
 /// <param name="message"></param>
 public abstract void OnReceived(MessageBody message);