![]() For more detail, you can visit its own official website. In this article, we demonstrated how to publish and consume the events with the eShopOnAbp project by using MassTransit. Log.Information($"Cancelled the order: ") Var payment = await _paymentRepository.GetAsync() Public async Task Consume(ConsumeContext context) Public OrderCancelledConsumer(IPaymentRequestRepository paymentRepository) Private readonly IPaymentRequestRepository _paymentRepository Let's create OrderCancelledConsumer in the public class OrderCancelledConsumer : IConsumer ![]() X.AddBus(provider => (cfg =>Ĭfg.ReceiveEndpoint("order-service", ep => Firstly let's implement the configuration in PaymentServiceHttpApiHostModule under the public class PaymentServiceHttpApiHostModule : AbpModule We're ready to focus on the consumer side (payment service). MassTransit provides a developer-focused, modern platform for creating distributed applications without complexity. Note: You can define your model OrderCancelledEto as a class, interface or record but MassTransit recommends record as the best practice. MassTransit provides a developer-focused, modern platform for creating distributed applications without complexity. Return await _orderRepository.UpdateAsync(order, autoSave: true) ![]() Items = GetProductItemEtoList(order.OrderItems) Just used _bus(IBus) instead of _distributedEventBus(IDistributedEventBus) Throw new BusinessException(OrderingServiceErrorCodes.OrderWithIdNotFound) Var order = await _orderRepository.GetAsync(orderId) Public async Task CancelOrderAsync(Guid orderId) public class OrderManager : DomainService Let's do its implemantation on OrderManager under Īs we mentioned above, the system already works properly so firstly we will remove/comment on the old published code and write the new codes. Install-Package MassTransit.RabbitMQ -Version 8.0.6 To complete this configuration you need to install the related packages on NuGet or via the below code Public override void ConfigureServices(ServiceConfigurationContext context) Let's do its configuration in OrderingServiceHttpApiHostModule under the public class OrderingServiceHttpApiHostModule : AbpModule The system already works properly, but we will make changes without touching the business logic code and use MassTransit abilities.įirstly, let's focus on the publishing event side (order service) and then we will focus on the consumer side (payment service). In this case, the just payment service will do that. In eShopOnAbp, once the order service cancels the order, it publishes an event. ![]() In this article, we will show you how to use MassTransit in the eShopOnAbp project instead of. We're planning to write some new articles about them. MassTransit also supports exceptions, retries, sagas, scheduling and more features. Also, you can implement the others easily as well. It works with different integrations.Īs you know, RabbitMQ is one of the most popular open-source message brokers which is used by many developers. MassTransit makes it easy to create applications and services. MassTransit is a lightweight service bus for building distributed. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |