コード例 #1
0
ファイル: SendingCompliance.cs プロジェクト: pkoronawa/jasper
        protected async Task <EnvelopeRecord> afterProcessingIsComplete()
        {
            _session = await theSender
                       .TrackActivity(_defaultTimeout)
                       .AlsoTrack(theReceiver)
                       .DoNotAssertOnExceptionsDetected()
                       .SendMessageAndWait(theMessage);

            return(_session.AllRecordsInOrder().LastOrDefault(x =>
                                                              x.EventType == EventType.MessageSucceeded || x.EventType == EventType.MovedToErrorQueue));
        }
コード例 #2
0
        protected async Task <EnvelopeRecord> afterProcessingIsComplete()
        {
            using (var host = JasperHost.For(theOptions))
            {
                _session = await host
                           .TrackActivity()
                           .DoNotAssertOnExceptionsDetected()
                           .SendMessageAndWait(theMessage);

                return(_session.AllRecordsInOrder().LastOrDefault(x =>
                                                                  x.EventType == EventType.MessageSucceeded || x.EventType == EventType.MovedToErrorQueue));
            }
        }
コード例 #3
0
ファイル: end_to_end.cs プロジェクト: pkoronawa/jasper
        public async Task send_multiple_messages_in_order()
        {
            var colorsChosens = Enumerable.Range(0, 100).Select(i => new ColorChosen {
                Name = i.ToString()
            });
            var sequence = Guid.NewGuid().ToString();

            using var host = JasperHost.For(host =>
            {
                host.Endpoints.ConfigureKafka();
                host.Endpoints.ListenToKafkaTopic("messages", ConsumerConfig).Sequential();
                host.Endpoints.Publish(pub => pub.Message <ColorChosen>().ToKafkaTopic("messages", ProducerConfig)
                                       .CustomizeOutgoing(e => e.Headers.Add("MessageKey", sequence)) // use the same message key in Kafka
                                       );
                host.Handlers.IncludeType <ColorHandler>();
                host.Services.AddSingleton <ColorHistory>();
                host.Extensions.UseMessageTrackingTestingSupport();
            });

            ITrackedSession session = await host
                                      .TrackActivity()
                                      .Timeout(60.Seconds())
                                      .IncludeExternalTransports()
                                      .ExecuteAndWait(async ctx =>
            {
                foreach (ColorChosen colorsChosen in colorsChosens)
                {
                    await ctx.Publish(colorsChosen);
                }
            });

            IEnumerable <string> colorsSent = session.AllRecordsInOrder()
                                              .Where(e => e.EventType == EventType.Sent)
                                              .Select(e => e.Envelope.Message).Cast <ColorChosen>().Select(c => c.Name);
            IEnumerable <string> colorsPublished = colorsChosens.Select(c => c.Name);

            colorsSent.ShouldBe(colorsPublished);
        }
コード例 #4
0
 private IList <MessageRecord> sent()
 {
     return(_session.AllRecordsInOrder(EventType.Received).Select(x =>
                                                                  new MessageRecord(x.ServiceName, x.Envelope.Destination, (Message)x.Envelope.Message)).ToList());
 }