Ejemplo n.º 1
0
 public void consumer_received(object o, BasicDeliverEventArgs e)
 {
     try
     {
         var result = EventMessage.BuildMessageResult(e.Body);
         if (_actionMessage.IsNotNull())
         {
             _actionMessage(result);
         }
         if (result.IsOperationOk.IsFalse())
         {
             //如果没有消费,重新放回队列
             Context.ListenCannel.BasicReject(e.DeliveryTag, true);
         }
         else if (Context.ListenCannel.IsClosed.IsFalse())
         {
             //如果没有关闭,返回状态
             Context.ListenCannel.BasicAck(e.DeliveryTag, true);
         }
     }
     catch (Exception)
     {
         throw new Exception();
     }
 }
Ejemplo n.º 2
0
 public void constomer_Recevied(object o, BasicDeliverEventArgs e)
 {
     try
     {
         var result = EventMessage.BuildMessageResult(e.Body);
         if (_actionMessage.IsNotNull())
         {
             _actionMessage(result);
         }
         if (result.IsOperationOk.IsFalse())
         {
             //未消费,重新放入消费队列
             Context.ListenCannel.BasicReject(e.DeliveryTag, false);
         }
         else if (Context.ListenCannel.IsClosed.IsFalse())
         {
             Context.ListenCannel.BasicAck(e.DeliveryTag, false);
         }
     }
     catch (Exception)
     {
         throw new Exception("消费者错误");
     }
 }