mainetrio.blogg.se

Masstransit handler
Masstransit handler













Thus, When the requester initiates a message ( event ) To RabbitMQ, After listening and processing, the response side returns the processing result to RabbitMQ, The requester continues to execute subsequent requests according to the response result. Var response = await _client.GetResponse(new ") Public OrderController(IRequestClient client) Public class OrderController : ControllerBase x.AddRequestClient(new Uri(GetServiceAddress("events-checkorderstatus"))) Īdd one more Controller And Action, To request and obtain processing results (OrderStatusResult). Stay Startup Add a new one to send messages (CheckOrderStatus) Request client and specify message queue name ( Create a separate queue for each message ). On a publish subscribe basis, Change your old habits, When a message is released, Waiting for the subscriber to process, And push the message back to RabbitMQ, The sender receives the processed message and continues to execute. In this way, adopt Postman Send a request, Send a message to RabbitMQ, Subscribers listen for messages, Process the message, Everything is familiar.

  • Add an acceptance point, Specify the queue name, The name of the queue sent by the sender, Set the consumption processing of the queue Consumer, namely ValueEnteredEventConsumerĬfg.ReceiveEndpoint("events-valueentered", e =>.
  • Add a subscription processing for the subscriber Handler, It is as follows ValueEnteredEventConsumer.
  • The subscriber also creates a WebApi application, stay Startup add MassTransit Service for, Used Nuget Packages are the same as publishers. Public ValueController(IPublishEndpoint publishEndpoint) Readonly IPublishEndpoint _publishEndpoint Public class ValueController : ControllerBase In order to quickly understand, Use Controller stay Action In the middle of MQ The news push X.AddRequestClient(new Uri(GetServiceAddress("events-valueentered")))

    masstransit handler

    Ĭfg.Host(Configuration, ushort.Parse(Configuration), Configuration, h =>

  • Initialize a request client for the message that the sender needs to send, Configure request information and push it to MQ The address of.
  • #Masstransit handler password

    Yes RabbitMQ Connection address port for 、 Virtual host 、 Access account password and other series configuration.Stay Startup add MassTransit Required services and initialization configuration. īased on the need to build two WebApi Program, Used to simulate senders and subscribers, Among them RabbitMQ It's pre built, You can only refer to the package configuration in the program. This kind of scene is very common, Send a message ( Or event ) Go to the message queue, There are one or more subscribers to the expected message reception processing. Official website address : Publish subscribe mode

    masstransit handler

    Message based communication is a reliable and scalable way to implement a service-oriented architecture. MassTransit Provides a wide range of capabilities over existing messaging, So that developers can use message based session mode to connect services asynchronously. It is convenient to build applications and services of loosely coupled asynchronous communication based on message. Net frame, For creating distributed applications. MassTransit It's a freedom 、 Open source 、 The lightweight message bus is based on.













    Masstransit handler