本文整理汇总了C#中RabbitMQ.Client.Events.BasicDeliverEventArgs.MessageId方法的典型用法代码示例。如果您正苦于以下问题:C# BasicDeliverEventArgs.MessageId方法的具体用法?C# BasicDeliverEventArgs.MessageId怎么用?C# BasicDeliverEventArgs.MessageId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RabbitMQ.Client.Events.BasicDeliverEventArgs
的用法示例。
在下文中一共展示了BasicDeliverEventArgs.MessageId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public virtual ChannelMessage Build(BasicDeliverEventArgs message)
{
if (message == null)
throw new ArgumentNullException("message");
try
{
var result = this.Translate(message);
this.AppendHeaders(result, message.BasicProperties);
return result;
}
catch (SerializationException e)
{
Log.Error("Unable to deserialize message '{0}'.".FormatWith(message.MessageId()), e);
throw new PoisonMessageException(e.Message, e);
}
catch (DeadLetterException)
{
throw;
}
catch (Exception e)
{
Log.Error("General deserialize error for message '{0}'.".FormatWith(message.MessageId()), e);
throw new PoisonMessageException(e.Message, e);
}
}
示例2: TryReceive
protected virtual void TryReceive(BasicDeliverEventArgs message, Action<IDeliveryContext> callback)
{
var messageId = message.MessageId();
try
{
Log.Verbose("Translating wire-specific message into channel message.");
this.CurrentMessage = this.adapter.Build(message);
Log.Info("Routing message '{0}' received through group '{1}' to configured receiver callback.", messageId, this.configuration.GroupName);
callback(this);
}
catch (ChannelConnectionException)
{
Log.Warn("The channel has become unavailable, aborting current transaction.");
this.CurrentTransaction.TryDispose();
throw;
}
catch (PoisonMessageException e)
{
Log.Warn("Wire message {0} could not be deserialized; forwarding to poison message exchange.", messageId);
this.ForwardToPoisonMessageExchange(message, e);
}
catch (DeadLetterException)
{
Log.Info("Wire message {0} has expired on the wire; forwarding to dead-letter exchange.", messageId);
this.ForwardTo(message, this.configuration.DeadLetterExchange);
}
catch (Exception e)
{
this.RetryMessage(message, e);
}
}
示例3: RetryMessage
protected virtual void RetryMessage(BasicDeliverEventArgs message, Exception exception)
{
var nextAttempt = this.AppendException(message, exception) + 1;
Log.Debug("Message '{0}' has been attempted {1} times.", message.MessageId(), nextAttempt);
if (nextAttempt > this.configuration.MaxAttempts)
{
Log.Error("Unable to process message '{0}'".FormatWith(message.MessageId()), exception);
this.ForwardToPoisonMessageExchange(message, null);
}
else
{
Log.Info("Unhandled exception for message '{0}'; retrying.".FormatWith(message.MessageId()), exception);
this.ForwardTo(message, this.configuration.InputQueue.ToPublicationAddress());
}
}
示例4: Send
protected virtual void Send(BasicDeliverEventArgs message, PublicationAddress recipient)
{
if (recipient == null)
return;
if (recipient == this.configuration.DeadLetterExchange)
this.adapter.AppendRetryAddress(message);
this.EnsureTransaction().Register(() => this.Try(() =>
{
Log.Info("Dispatching wire message '{0}' to messaging infrastructure for recipient '{1}'.", message.MessageId(), recipient);
this.channel.BasicPublish(recipient, message.BasicProperties, message.Body);
}));
}
示例5: ForwardTo
protected virtual void ForwardTo(BasicDeliverEventArgs message, PublicationAddress address)
{
Log.Debug("Forwarding message '{0}' to recipient '{1}'.", message.MessageId(), address);
this.EnsureTransaction();
this.Send(message, address);
this.CurrentTransaction.Commit();
}
示例6: ForwardToPoisonMessageExchange
protected virtual void ForwardToPoisonMessageExchange(BasicDeliverEventArgs message, Exception exception)
{
Log.Info("Message '{0}' is a poison message.", message.MessageId());
this.AppendException(message, exception);
message.SetAttemptCount(0);
this.adapter.AppendRetryAddress(message);
this.ForwardTo(message, this.configuration.PoisonMessageExchange);
}
示例7: RetryMessage
protected virtual void RetryMessage(BasicDeliverEventArgs message, Exception exception)
{
var nextAttempt = message.GetAttemptCount() + 1;
message.SetAttemptCount(nextAttempt);
// 0-based to 1-based value
Log.Debug("Message '{0}' has been attempted {1} times.", message.MessageId(), nextAttempt);
if (nextAttempt > this.configuration.MaxAttempts)
this.ForwardToPoisonMessageExchange(message, exception);
else
this.ForwardTo(message, this.configuration.InputQueue.ToPublicationAddress());
}