• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Runtime.Envelope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中FubuTransportation.Runtime.Envelope的典型用法代码示例。如果您正苦于以下问题:C# Envelope类的具体用法?C# Envelope怎么用?C# Envelope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Envelope类属于FubuTransportation.Runtime命名空间,在下文中一共展示了Envelope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: create_from_graph_and_run_through_the_channel

        public void create_from_graph_and_run_through_the_channel()
        {
            using (var graph = new ChannelGraph())
            {
                var node = graph.ChannelFor<BusSettings>(x => x.Outbound);

                node.Uri = new Uri("memory://foo");

                var transport = new InMemoryTransport();
                transport.OpenChannels(graph);
                node.Channel.ShouldNotBeNull();

                var envelope = new Envelope();
                envelope.CorrelationId = Guid.NewGuid().ToString();
                envelope.Headers["Foo"] = "Bar";
                envelope.Data = new byte[] {1, 2, 3, 4, 5};

                var receiver = new RecordingReceiver();

                node.StartReceiving(receiver);

                node.Channel.Send(envelope.Data, envelope.Headers);

                Wait.Until(() => receiver.Received.Any(), timeoutInMilliseconds: 2000);

                var received = receiver.Received.Single();

                received.CorrelationId.ShouldEqual(envelope.CorrelationId);
                received.ContentType.ShouldEqual(envelope.ContentType);
                received.Data.ShouldEqual(envelope.Data);

            }
        }
开发者ID:JackGilliam1,项目名称:FubuTransportation,代码行数:33,代码来源:InMemoryQueueIntegrationTester.cs


示例2: SetUp

        public void SetUp()
        {
            theContext = new TestContinuationContext();
            theEnvelope = ObjectMother.Envelope();

            new NoSubscriberHandler().Execute(theEnvelope, theContext);
        }
开发者ID:RyanHauert,项目名称:FubuTransportation,代码行数:7,代码来源:NoSubscriberHandlerTester.cs


示例3: recovers_delayed_messages_when_started

        public void recovers_delayed_messages_when_started()
        {
            using (var queues = new PersistentQueues(new RecordingLogger(), new DelayedMessageCache<MessageId>(), new LightningQueueSettings()))
            {
                queues.ClearAll();
                queues.Start(new []{ new LightningUri("lq.tcp://localhost:2425/the_queue") });

                var envelope = new Envelope();
                envelope.Data = new byte[0];
                envelope.ExecutionTime = DateTime.UtcNow;
                var delayedMessage = new MessagePayload
                {
                    Data = envelope.Data,
                    Headers = envelope.Headers.ToNameValues()
                };

                using (var scope = new TransactionScope())
                {
                    queues.ManagerFor(2425, true)
                        .EnqueueDirectlyTo(LightningQueuesTransport.DelayedQueueName, null, delayedMessage);
                    scope.Complete();
                }
            }

            var cache = new DelayedMessageCache<MessageId>();
            using (var queues = new PersistentQueues(new RecordingLogger(), cache, new LightningQueueSettings()))
            {
                queues.Start(new []{ new LightningUri("lq.tcp://localhost:2425/the_queue") });

                cache.AllMessagesBefore(DateTime.UtcNow.AddSeconds(1)).ShouldNotBeEmpty();
            }
        }
开发者ID:RyanHauert,项目名称:FubuTransportation,代码行数:32,代码来源:PersistentQueueTester.cs


示例4: Send

        // virtual for testing
        public string Send(Envelope envelope)
        {
            envelope.Headers[Envelope.MessageTypeKey] = envelope.Message.GetType().FullName;

            _modifiers.Each(x => x.Modify(envelope));

            var channels = _router.FindDestinationChannels(envelope).ToArray();

            if (!channels.Any())
            {
                throw new Exception("No channels match this message ({0})".ToFormat(envelope));
            }

            channels.Each(x => {
                try
                {
                    sendToChannel(envelope, x);
                }
                catch (Exception e)
                {
                    _logger.Error(envelope.CorrelationId, "Failed trying to send message {0} to channel {1}".ToFormat(envelope, x.Uri), e);
                    throw;
                }
            });

            return envelope.CorrelationId;
        }
开发者ID:RyanHauert,项目名称:FubuTransportation,代码行数:28,代码来源:EnvelopeSender.cs


示例5: Execute

        public void Execute(Envelope envelope, ContinuationContext context)
        {
            context.Outgoing.SendFailureAcknowledgement(envelope, "Moved message {0} to the Error Queue.\n{1}".ToFormat(envelope.CorrelationId, _exception));

            var report = new ErrorReport(envelope, _exception);
            envelope.Callback.MoveToErrors(report);
        }
开发者ID:JackGilliam1,项目名称:FubuTransportation,代码行数:7,代码来源:MoveToErrorQueue.cs


示例6: Receive

        public void Receive(byte[] data, IHeaders headers, IMessageCallback callback)
        {
            var envelope = new Envelope(data, headers, callback);
            Received.Add(envelope);

            envelope.Callback.MarkSuccessful();
        }
开发者ID:JackGilliam1,项目名称:FubuTransportation,代码行数:7,代码来源:RecordingReceiver.cs


示例7: DequeueDelayedEnvelopes

        public static IEnumerable<EnvelopeToken> DequeueDelayedEnvelopes(DateTime currentTime)
        {
            var delayed = _delayedLock.Read(() => {
                return _delayed.Where(x => new Envelope(x.Headers).ExecutionTime.Value <= currentTime).ToArray();
            });

            var list = new List<EnvelopeToken>();

            foreach (EnvelopeToken token in delayed)
            {
                _delayedLock.Write(() => {
                    try
                    {
                        _delayed.Remove(token);

                        var envelope = new Envelope(token.Headers);
                        _queues[envelope.ReceivedAt].Enqueue(token);

                        list.Add(token);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex);
                    }
                });

            }

            return list;
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:30,代码来源:InMemoryQueueManager.cs


示例8: MonitoringControlHandler

 public MonitoringControlHandler(ILogger logger, Envelope envelope, ChannelGraph graph, IPersistentTaskController controller)
 {
     _logger = logger;
     _envelope = envelope;
     _graph = graph;
     _controller = controller;
 }
开发者ID:RyanHauert,项目名称:FubuTransportation,代码行数:7,代码来源:MonitoringControlHandler.cs


示例9: SetUp

        public void SetUp()
        {
            _envelope = ObjectMother.Envelope();
            _message = new object();
            _context = new TestContinuationContext();

            new RespondWithMessageContinuation(_message).Execute(_envelope, _context);
        }
开发者ID:RyanHauert,项目名称:FubuTransportation,代码行数:8,代码来源:RespondWithMessageContinuationTester.cs


示例10: SetUp

 public void SetUp()
 {
     theMessage = new Message1();
     theOriginalEnvelope = new Envelope
     {
         ReplyUri = "lq://foo".ToUri()
     };
 }
开发者ID:JordanZaerr,项目名称:FubuTransportation,代码行数:8,代码来源:RespondTester.cs


示例11: attempts

        public void attempts()
        {
            var envelope = new Envelope();
            envelope.Attempts.ShouldEqual(0);

            envelope.Attempts++;

            envelope.Attempts.ShouldEqual(1);
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:9,代码来源:EnvelopeTester.cs


示例12: ExceptionHandlerBehavior

 public ExceptionHandlerBehavior(IActionBehavior behavior, HandlerChain chain, Envelope envelope, IInvocationContext context, ILogger logger, IFubuRequest request)
 {
     _behavior = behavior;
     _chain = chain;
     _envelope = envelope;
     _context = context;
     _logger = logger;
     _request = request;
 }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:9,代码来源:ExceptionHandlerBehavior.cs


示例13: SendSubscriptionChangedToPeer

        public virtual void SendSubscriptionChangedToPeer(TransportNode node)
        {
            var envelope = new Envelope
            {
                Message = new SubscriptionsChanged(),
                Destination = node.Addresses.FirstOrDefault()
            };

            _sender.Send(envelope);
        }
开发者ID:JackGilliam1,项目名称:FubuTransportation,代码行数:10,代码来源:SubscriptionsHandler.cs


示例14: matches_negative_with_no_execution_time_header

        public void matches_negative_with_no_execution_time_header()
        {
            var systemTime = SystemTime.Default();
            var envelope = new Envelope();

            var handler = new DelayedEnvelopeHandler(systemTime);

            envelope.IsDelayed(systemTime.UtcNow()).ShouldBeFalse();
            handler.Matches(envelope).ShouldBeFalse();
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:10,代码来源:DelayedEnvelopeHandlerTester.cs


示例15: SetUp

        public void SetUp()
        {
            theException = new EnvelopeDeserializationException("foo");
            theContext = new TestContinuationContext();

            theEnvelope = ObjectMother.EnvelopeWithSerializationError();

            new DeserializationFailureContinuation(theException)
                .Execute(theEnvelope, theContext);
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:10,代码来源:DeserializationFailureContinuationTester.cs


示例16: ErrorReport

        public object Message; // leave it like this please

        #endregion Fields

        #region Constructors

        public ErrorReport(Envelope envelope, Exception ex)
        {
            Headers = envelope.Headers.ToNameValues();
            ExceptionText = ex.ToString();
            ExceptionMessage = ex.Message;
            ExceptionType = ex.GetType().FullName;
            Explanation = ExceptionDetected;
            RawData = envelope.Data;
            Message = envelope.Message;
        }
开发者ID:RyanHauert,项目名称:FubuTransportation,代码行数:16,代码来源:ErrorReport.cs


示例17: default_values_for_original_and_parent_id_are_null

        public void default_values_for_original_and_parent_id_are_null()
        {
            var parent = new Envelope
            {
                CorrelationId = Guid.NewGuid().ToString()
            };

            parent.OriginalId.ShouldBeNull();
            parent.ParentId.ShouldBeNull();
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:10,代码来源:EnvelopeTester.cs


示例18: content_type

        public void content_type()
        {
            var envelope = new Envelope();
            envelope.ContentType.ShouldEqual(null);

            envelope.ContentType = "text/xml";

            envelope.Headers[Envelope.ContentTypeKey].ShouldEqual("text/xml");
            envelope.ContentType.ShouldEqual("text/xml");
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:10,代码来源:EnvelopeTester.cs


示例19: SetUp

        public void SetUp()
        {
            theEnvelope = ObjectMother.Envelope();
            theException = new NotImplementedException();

            theLogger = MockRepository.GenerateMock<ILogger>();

            theContext = new TestContinuationContext();

            new MoveToErrorQueue(theException).Execute(theEnvelope, theContext);
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:11,代码来源:MovetoErrorQueueTester.cs


示例20: Send

        public override IHeaders Send(Envelope envelope, IEnvelopeSerializer serializer, Uri replyUri = null)
        {
            if (replyUri != null)
            {
                envelope.ReplyUri = replyUri;
            }

            LastEnvelope = envelope;

            return envelope.Headers;
        }
开发者ID:RyanHauert,项目名称:FubuTransportation,代码行数:11,代码来源:StubChannelNode.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# X86.Addr32类代码示例发布时间:2022-05-26
下一篇:
C# Routes.RouteParameters类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap