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


C# BrokeredMessage.DeadLetter方法代码示例

本文整理汇总了C#中BrokeredMessage.DeadLetter方法的典型用法代码示例。如果您正苦于以下问题:C# BrokeredMessage.DeadLetter方法的具体用法?C# BrokeredMessage.DeadLetter怎么用?C# BrokeredMessage.DeadLetter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BrokeredMessage的用法示例。


在下文中一共展示了BrokeredMessage.DeadLetter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnBrokerMessage

        private void OnBrokerMessage(BrokeredMessage brokeredMessage)
        {
            try
            {
                //Ignore messages from self
                if (brokeredMessage.Properties[SidAttributeName].ToString() == _sid)
                {
                    brokeredMessage.Complete();
                    return;
                }

                var json = brokeredMessage.Properties[DataAttributeName].ToString();
                var message = _jsonSerializer.DeserializeFromString<Message>(json);

                var pipeline = Composable.GetExport<IXSocketPipeline>();
                var controller = Composable.GetExports<IXSocketController>().First(p => p.Alias == message.Controller);
                controller.ProtocolInstance = new XSocketInternalProtocol();
                pipeline.OnIncomingMessage(controller, message);
                brokeredMessage.Complete();
            }
            catch (Exception ex)
            {
                Composable.GetExport<IXLogger>().Error(ex.ToString());

                // Indicates a problem
                if (brokeredMessage.DeliveryCount > 3)
                {
                    brokeredMessage.DeadLetter();
                }
                else
                {
                    brokeredMessage.Abandon();
                }
            }
        }
开发者ID:acandocodecamp,项目名称:xsockets,代码行数:35,代码来源:AzureServiceBusScaleout.cs

示例2: OnMessageReceived

        private void OnMessageReceived( BrokeredMessage message )
        {
            object payload;
            using ( var stream = message.GetBody<Stream>() )
            using ( var reader = new StreamReader( stream ) )
            {
                try
                {
                    payload = this.serializer.Deserialize( reader );
                }
                catch ( SerializationException e )
                {
                    message.DeadLetter( e.Message, e.ToString() );
                    return;
                }
            }

            ProcessMessage( payload, message.MessageId, message.CorrelationId );
            message.Complete();
        }
开发者ID:nghiaminhle,项目名称:ddd-cqrs-cqrs-es,代码行数:20,代码来源:MessageProcessor.cs

示例3: OnMessage

        private void OnMessage(BrokeredMessage message)
        {
            try
            {
                if (OnMessageReceived != null)
                {
                    var headers = ResolveMessageHeaders(message);
                    var bodyStream = message.GetBody<Stream>();
                    var channelMessage = new ChannelMessage(bodyStream);
                    channelMessage.AddHeader(headers);
                    OnMessageReceived(this, new MessageReceivedEventArgs { Message = channelMessage });
                }

                message.Complete();
            }
            catch (Exception ex)
            {
                message.DeadLetter();
                throw;
            }
        }
开发者ID:Zapote,项目名称:EzBus,代码行数:21,代码来源:ServiceBusReceivingChannel.cs

示例4: OnBrokerMessage

 private void OnBrokerMessage(BrokeredMessage message)
 {
     try
     {
         Composable.GetExport<IXLogger>().Debug("Message Arrived {@m}", message);
         var m = this.Serializer.DeserializeFromString<Message>(message.Properties["JSON"].ToString());
         var pipe = Composable.GetExport<IXSocketPipeline>();
         var ctrl = Composable.GetExports<IXSocketController>().First(p => p.Alias == m.Controller);
         ctrl.ProtocolInstance = new XSocketInternalProtocol();
         pipe.OnIncomingMessage(ctrl, m);
         message.Complete();
     }
     catch (Exception)
     {
         // Indicates a problem, unlock message in subscription
         if (message.DeliveryCount > 3)
             message.DeadLetter();
         else
             message.Abandon();
     }
 }
开发者ID:uffebjorklund,项目名称:HackZurich,代码行数:21,代码来源:AzureServiceBusScaleOut.cs

示例5: SafeDeadLetter

            static bool SafeDeadLetter(BrokeredMessage msg, string reason) {
                try {
                    // Mark brokered message as complete.
                    msg.DeadLetter(reason, "Max retries Exceeded.");

                    // Return a result indicating that the message has been completed successfully.
                    return true;
                }
                catch (MessageLockLostException) {
                    // It's too late to compensate the loss of a message lock. We should just ignore it so that it does not break the receive loop.
                    // We should be prepared to receive the same message again.
                }
                catch (MessagingException) {
                    // There is nothing we can do as the connection may have been lost, or the underlying topic/subscription may have been removed.
                    // If Complete() fails with this exception, the only recourse is to prepare to receive another message (possibly the same one).
                }

                return false;
            }
开发者ID:tcabanski,项目名称:ProjectExtensions.Azure.ServiceBus,代码行数:19,代码来源:AzureBusReceiver.cs

示例6: Handle

        private async Task Handle(BrokeredMessage brokeredMessage)
        {
            dynamic innerMessage = JsonConvert.DeserializeObject(brokeredMessage.GetBody<string>(),
                new JsonSerializerSettings
                {
                    TypeNameHandling = TypeNameHandling.All,
                    DateFormatHandling = DateFormatHandling.IsoDateFormat
                }) as IMessage;

            try
            {
                await _dispatcher.Handle(innerMessage);

                await brokeredMessage.CompleteAsync();
            }
            catch (Exception exception)
            {
                if (brokeredMessage.DeliveryCount >= 5)
                {
                    brokeredMessage.DeadLetter(exception.GetBaseException().Message, exception.GetBaseException().ToString());
                }

                brokeredMessage.Abandon();
            }
        }
开发者ID:RichardW1001,项目名称:MessagingStuff,代码行数:25,代码来源:MessageBus.cs


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