本文整理汇总了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);
}
}
示例2: SetUp
public void SetUp()
{
theContext = new TestContinuationContext();
theEnvelope = ObjectMother.Envelope();
new NoSubscriberHandler().Execute(theEnvelope, theContext);
}
示例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();
}
}
示例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;
}
示例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);
}
示例6: Receive
public void Receive(byte[] data, IHeaders headers, IMessageCallback callback)
{
var envelope = new Envelope(data, headers, callback);
Received.Add(envelope);
envelope.Callback.MarkSuccessful();
}
示例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;
}
示例8: MonitoringControlHandler
public MonitoringControlHandler(ILogger logger, Envelope envelope, ChannelGraph graph, IPersistentTaskController controller)
{
_logger = logger;
_envelope = envelope;
_graph = graph;
_controller = controller;
}
示例9: SetUp
public void SetUp()
{
_envelope = ObjectMother.Envelope();
_message = new object();
_context = new TestContinuationContext();
new RespondWithMessageContinuation(_message).Execute(_envelope, _context);
}
示例10: SetUp
public void SetUp()
{
theMessage = new Message1();
theOriginalEnvelope = new Envelope
{
ReplyUri = "lq://foo".ToUri()
};
}
示例11: attempts
public void attempts()
{
var envelope = new Envelope();
envelope.Attempts.ShouldEqual(0);
envelope.Attempts++;
envelope.Attempts.ShouldEqual(1);
}
示例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;
}
示例13: SendSubscriptionChangedToPeer
public virtual void SendSubscriptionChangedToPeer(TransportNode node)
{
var envelope = new Envelope
{
Message = new SubscriptionsChanged(),
Destination = node.Addresses.FirstOrDefault()
};
_sender.Send(envelope);
}
示例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();
}
示例15: SetUp
public void SetUp()
{
theException = new EnvelopeDeserializationException("foo");
theContext = new TestContinuationContext();
theEnvelope = ObjectMother.EnvelopeWithSerializationError();
new DeserializationFailureContinuation(theException)
.Execute(theEnvelope, theContext);
}