本文整理汇总了C#中IMessageContext.Acknowledge方法的典型用法代码示例。如果您正苦于以下问题:C# IMessageContext.Acknowledge方法的具体用法?C# IMessageContext.Acknowledge怎么用?C# IMessageContext.Acknowledge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMessageContext
的用法示例。
在下文中一共展示了IMessageContext.Acknowledge方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleMessage
public Task HandleMessage(object content, IMessageContext messageContext,
CancellationToken cancellationToken = default(CancellationToken))
{
Log.DebugFormat("Handling message ID {0}...", messageContext.Headers.MessageId);
HandledMessageQueue.Enqueue(content);
messageContext.Acknowledge();
MessageReceivedEvent.Set();
return Task.FromResult(true);
}
示例2: HandleMessage
public async Task HandleMessage(object content, IMessageContext context, CancellationToken cancellationToken)
{
var testMessage = (TestMessage) content;
Log.DebugFormat("[Process {0}, Thread {1}, AppDomain {2}]",
Process.GetCurrentProcess().Id,
Thread.CurrentThread.ManagedThreadId,
AppDomain.CurrentDomain.Id);
var headers = context.Headers;
Log.DebugFormat("Handling {0} ID {1} sent from {2} by {3} at {4:o} and received {5:o}...",
headers.MessageName,
headers.MessageId,
headers.Origination,
context.SenderPrincipal.GetName(),
headers.Sent,
headers.Received);
var receivedMessage = new ReceivedMessage
{
SenderPrincipal = context.SenderPrincipal == null ? null : context.SenderPrincipal.Identity.Name,
MessageId = headers.MessageId,
MessageName = headers.MessageName,
Origination = headers.Origination == null ? "" : headers.Origination.ToString(),
Destination = headers.Destination == null ? "" : headers.Destination.ToString(),
RelatedTo = headers.RelatedTo,
Sent = headers.Sent,
Received = headers.Received,
Expires = headers.Expires,
ContentType = headers.ContentType,
Content = testMessage == null ? "" : testMessage.Text
};
await _repository.Add(receivedMessage);
context.Acknowledge();
Log.DebugFormat("{0} ID {1} handled successfully",
headers.MessageName,
headers.MessageId);
}
示例3: HandleMessage
public static async Task HandleMessage(IMessageNamingService messageNamingService,
ISerializationService serializationService, IEnumerable<IMessageHandler> messageHandlers, Message message,
IMessageContext messageContext, CancellationToken cancellationToken = default(CancellationToken))
{
if (message.Headers.Expires < DateTime.UtcNow)
{
Log.WarnFormat("Discarding expired \"{0}\" message (ID {1}, expired {2})", message.Headers.MessageName,
message.Headers.MessageId, message.Headers.Expires);
messageContext.Acknowledge();
return;
}
var messageType = messageNamingService.GetTypeForName(message.Headers.MessageName);
var serializer = serializationService.GetSerializer(message.Headers.ContentType);
var messageContent = serializer.Deserialize(message.Content, messageType);
var handlingTasks =
messageHandlers.Select(
handler => handler.HandleMessage(messageContent, messageContext, cancellationToken));
await Task.WhenAll(handlingTasks);
}
示例4: HandleMessage
public static async Task HandleMessage(TestMessage message, IMessageContext messageContext,
CancellationToken cancellationToken)
{
if (message.SimulateAuthorizationFailure)
{
throw new UnauthorizedAccessException();
}
await messageContext.SendReply(new TestReply
{
GuidData = message.GuidData,
IntData = message.IntData,
StringData = message.StringData,
DateData = message.DateData
}, cancellationToken: cancellationToken);
if (message.SimulateAcknowledgementFailure)
{
return;
}
messageContext.Acknowledge();
}
示例5: HandleMessage
public Task HandleMessage(object content, IMessageContext messageContext, CancellationToken cancellationToken)
{
MessageReceivedEvent.Set();
messageContext.Acknowledge();
return Task.FromResult(true);
}