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


C# Runtime.Envelope类代码示例

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


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


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