![]() Return new(bookingCreated.BookingId, bookingSummary.FirstName, bookingSummary.LastName,ĭateTime.UtcNow, DateTime.UtcNow, carBooking.PickUpLocation, 100,Įnum.Parse(())) Var bookingSummary = bookingCreated.BookingSummary Var carBooking = bookingCreated.CarBooking Private static MapToCarBooking(BookingCreated bookingCreated) => new(bookingCreated.BookingId, bookingCreated.BookingSummary,īookingCreated.CarBooking, bookingCreated.HotelBooking, bookingCreated.FlightBooking) Private static CarBooked MapToCarBooked(BookingCreated bookingCreated) => await context.Publish(MapToCarBooked(bookingCreated)) Private static async Task PublishCarBookedAsync(ConsumeContext context, BookingCreated bookingCreated) => await _mediator.Send(new MakeCarBookingCommand(MapToCarBooking(bookingCreated))) Private async Task MakeCarBookingAsync(BookingCreated bookingCreated) Public async Task Consume(ConsumeContext context)Īwait MakeCarBookingAsync(bookingCreated) Īwait PublishCarBookedAsync(context, bookingCreated) Public BookingCreatedConsumer(IMediator mediator) Public class BookingCreatedConsumer : IConsumer Note that IMediator is injected using constructor injection: Why are things a little more interesting with MediatR? To answer that, let’s remind ourselves what our BookingCreatedConsumer looks like (see below). MassTransit and MediatR integration testing Send out a CarBooked message using MassTransit so that other downstream services can continue booking other things such as a hotel and flights.Call the CarBookingRepository (which makes an API call to a 3rd party Car Booking API).We’re going to continue with our Car Booking service we’ve been writing which does the below: MassTransit and MediatR – Part 3 – How to “dead letter” invalid messages with MassTransit, MediatR and FluentValidation.MassTransit and MediatR – Part 2 – How to configure exponential back off when retrying messages.MassTransit and MediatR – Part 1 – Initial set up of MassTransit and MediatR.If you’re interested in how to get MassTransit working with MediatR then take a look at my previous series: All the code for this can be found on my GitHub here. In this post, we’ll look at MassTransit and MediatR integration testing.
0 Comments
Leave a Reply. |