public AckEvent(MessageReceivedInfo info, MessageProperties properties, byte[] body, AckResult ackResult) { ReceivedInfo = info; Properties = properties; Body = body; AckResult = ackResult; }
public AckEvent(MessageReceivedInfo info, MessageProperties properties, byte[] body , AckResult ackResult) { ReceivedInfo = info; Properties = properties; Body = body; AckResult = ackResult; }
public void Setup() { model = MockRepository.GenerateStrictMock<IModel>(); model.Expect(m => m.BasicNack(deliveryTag, false, true)); result = AckStrategies.NackWithRequeue(model, deliveryTag); }
/// <summary> /// 发送ack回执 /// </summary> /// <param name="context"></param> /// <param name="ackStrategy"></param> private void DoAck(ConsumerExecutionContext context, AckStrategy ackStrategy) { const string failedToAckMessage = "Basic ack failed because channel was closed with message '{0}'." + " Message remains on RabbitMQ and will be retried." + " ConsumerTag: {1}, DeliveryTag: {2}"; AckResult ackResult = AckResult.Exception; try { Preconditions.CheckNotNull(context.Consumer.Model, "context.Consumer.Model"); ackResult = ackStrategy(context.Consumer.Model, context.Info.DeliverTag); } catch (AlreadyClosedException alreadyClosedException) { ConsoleLogger.InfoWrite(failedToAckMessage, alreadyClosedException.Message, context.Info.ConsumerTag, context.Info.DeliverTag); } catch (IOException ioException) { ConsoleLogger.InfoWrite(failedToAckMessage, ioException.Message, context.Info.ConsumerTag, context.Info.DeliverTag); } catch (Exception exception) { ConsoleLogger.ErrorWrite("Unexpected exception when attempting to ACK or NACK\n{0}", exception); } finally { EventBus.Instance.Publish(new AckEvent(context, ackResult)); } }
public void Setup() { model = MockRepository.GenerateStrictMock <IModel>(); model.Expect(m => m.BasicNack(deliveryTag, false, true)); result = AckStrategies.NackWithRequeue(model, deliveryTag); }
public override void MessageReceived(Paket paket) { var sequenceId = (ushort)(paket.Array[2] + (paket.Array[3] << 8)); paket.SeqId = sequenceId; #if UID paket.Offset = 8; paket.Uid = (uint)SimpleTypeReader.ReadInt(paket); #else paket.Offset = 8; #endif // TODO: playoutBuffer calls Playout into user code while having this lock. High deadlock danger when user calls back into send while the lock is held here lock (_lock) { Trace.Debug(">>> Received: {0}", paket); var sendAck = (paket.Array[1] & RequireAck) != 0; if ((paket.Array[1] & Empty) == 0) { _messageReceivedCounter++; var ackResult = _receivedOrderedAcknowledgePlayoutBuffers.Add(paket.SeqId, paket); // not sure whether lateAck is a reason to send acks. Following scenario: // 001 // 101 early ack // 111 late ack var ack = ackResult == AckResult.AlreadyAcked || ackResult == AckResult.EarlyAck || ackResult == AckResult.OutOfWindow; if (_messageReceivedCounter++ == 4) { _messageReceivedCounter = 0; _lastAckResult = AckResult.Unknown; } // Avoid flooding with empty packages. This could happen when for example a paket is missing but pakets // keep on arriving they all would come back here with "EarlyAck". However after 4 pakets we reset. if (ackResult != _lastAckResult) { sendAck |= ack; } _lastAckResult = ackResult; if (sendAck) { Trace.Debug("SendingAck because AckResult: {0}", ackResult); } } else { Trace.Debug("Received empty paket. Not adding to acks"); } if (ResendUnconfirmed(paket)) { sendAck = false; } if (sendAck) { SendEmptyPaket(Empty); } Trace.Debug("<<< Received: {0}", paket); Monitor.Pulse(_lock); } }
public AckEvent(ConsumerExecutionContext consumerExecutionContext, AckResult ackResult) { ConsumerExecutionContext = consumerExecutionContext; AckResult = ackResult; }
public NackWithRequeue_strategy() { model = Substitute.For <IModel>(); result = AckStrategies.NackWithRequeue(model, deliveryTag); }
public Ack_strategy() { model = Substitute.For <IModel>(); result = AckStrategies.Ack(model, deliveryTag); }
public Nothing_strategy() { model = Substitute.For <IModel>(); result = AckStrategies.Nothing(model, deliveryTag); }
public void Setup() { model = MockRepository.GenerateStrictMock<IModel>(); result = AckStrategies.Nothing(model, deliveryTag); }
public void Setup() { model = MockRepository.GenerateStrictMock <IModel>(); result = AckStrategies.Nothing(model, deliveryTag); }