当前位置: 首页>>代码示例>>C#>>正文


C# IMessageContext.Acknowledge方法代码示例

本文整理汇总了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);
 }
开发者ID:tdbrian,项目名称:Platibus,代码行数:9,代码来源:MessageHandlerStub.cs

示例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);
        }
开发者ID:tdbrian,项目名称:Platibus,代码行数:40,代码来源:ReceivedMessageHandler.cs

示例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);
        }
开发者ID:tdbrian,项目名称:Platibus,代码行数:22,代码来源:MessageHandler.cs

示例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();
        }
开发者ID:tdbrian,项目名称:Platibus,代码行数:22,代码来源:TestHandler.cs

示例5: HandleMessage

 public Task HandleMessage(object content, IMessageContext messageContext, CancellationToken cancellationToken)
 {
     MessageReceivedEvent.Set();
     messageContext.Acknowledge();
     return Task.FromResult(true);
 }
开发者ID:tdbrian,项目名称:Platibus,代码行数:6,代码来源:TestPublicationHandler.cs


注:本文中的IMessageContext.Acknowledge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。