public async Task tracking_correlation_id_on_everything() { var catcher = new EnvelopeCatcher(); var host = JasperHost.For(x => { x.Handlers.DisableConventionalDiscovery().IncludeType <ExecutedMessageGuy>(); x.Publish.AllMessagesTo("stub://outgoing"); x.Services.AddSingleton(catcher); }); try { var context = host.Get <IMessageContext>(); await context.Invoke(new ExecutedMessage()); catcher.Envelopes.Single().CorrelationId.ShouldBe(context.CorrelationId); await context.Send(new ExecutedMessage()); await context.Publish(new ExecutedMessage()); await context.ScheduleSend(new ExecutedMessage(), DateTime.UtcNow.AddDays(5)); var envelopes = host.GetAllEnvelopesSent(); foreach (var envelope in envelopes) { envelope.CorrelationId.ShouldBe(context.CorrelationId); } } finally { host.Dispose(); } }
public static void Handle(ExecutedMessage message, Envelope envelope, EnvelopeCatcher catcher) { catcher.Envelopes.Add(envelope); }