Xamarinwatchos xamarinwatchos was computed.In the previous post we explored how to inject a dependency into the registered consumer class in MassTransit. netstandard2.1 netstandard2.1 was computed. Netstandard2.0 netstandard2.0 is compatible. netcoreapp3.1 netcoreapp3.1 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp2.1 netcoreapp2.1 was computed. Netcoreapp2.0 netcoreapp2.0 was computed. net7.0-windows net7.0-windows was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-android net7.0-android was computed. net6.0-windows net6.0-windows was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-android net6.0-android was computed. net5.0-windows net5.0-windows was computed. Versions Compatible and additional computed target framework versions. Server publishes an event for the command it processed.Server responds to client with a success message.When the command is successfully consumed.MassTransit moves failed messages to a special _error queue: the audit service consumes these messages and logs them.The retry fails so the server responds with an exception to the client.If it succeeds this time then the normal success procedure is followed. Server will randomly fail to consume a command.Client sends a command to server command queue.Whilst the example is running you can browse to localhost:15672 to see the RabbitMQ management console i.e. Run Run-Example.ps1 to see it working at scale in docker-compose. See example/Example.Client for an example client (of a specific command), server (of that specific command) and auditing microservices. Return await requestClient.Request(command, cancellationToken) Var requestClient = _configuredSendEndpointProvider.GetRequestClient() Public async Task SendSomeCommand(ISomeCommand command, CancellationToken cancellationToken = default) _configuredSendEndpointProvider = configuredSendEndpointProvider Public SomeClient(IConfiguredSendEndpointProvider configuredSendEndpointProvider) Private readonly IConfiguredSendEndpointProvider _configuredSendEndpointProvider Respond to client, preserving correlation ID.Īwait context.RespondAsync(new ) Ĭlients should inject IConfiguredSendEndpointProvider and call GetRequestClient() for request-response or GetSendEndpoint() for fire-and-forget e.g. Public async Task Consume(ConsumeContext context) Registered consumers should inherit IConsumer for example: public class CommandConsumer : IConsumer WithSendEndpointB圜onvention("some_remote_application") The convention is identical to the request-response endpoint above. Setting up an endpoint by convention that supports the fire-and-forget pattern. WithRequestResponseSendEndpointB圜onvention("some_remote_application") The remote application should have a consumer setup with this interface by convention. The convention based endpoint will send commands to some_remote_application_some_other_command. Setting up an endpoint by convention that supports the request-response pattern. Consuming by convention (a queue named some_application_name_some_command) with a single immediate retry. Services.AddMassTransitRabbitMqHostedService("some_application_name", massTransitOptions) It must be shared with clients wishing to send a command. The application name will be prefixed to all consumer queues. Var massTransitOptions = _configuration.GetMassTransitOptionsConnectionString() You need a RabbitMQ connection string with a amqp scheme for this to work. To use in Startup.cs in ASP.Net Core or IHostBuilder.ConfigureServices in a hosted service application: public IServiceProvider ConfigureServices(IServiceCollection services) Endpoint configuration at DI setup time: means we're not passing around connection strings everywhere.Setup via connection string with amqp scheme.Supports starting the application without RabbitMQ being present: the first time the bus is used, the request thread will block until RabbitMQ is available.Provides an that manages the massTransit bus lifetime as part of ASP.Net Core or the new hosted service provider.There is official support for this but it is very poor - it literally only supports consumer injection and no way of assigning consumers to distinct receive endpoints. Provides a standard configuration mechanism based on.Some features over just consuming the MassTransit NuGet package directly: Standard error queues for auditing/debugging hard failed request-response commands.Standard fault queues for catching/auditing failed fire-and-forget commands.Simplified concept of commands by whether they expect a response or are fire-and-forget.Exchange routing via remote microservice name.Some conventions assumed in this package: MassTransit configuration extensions for using and RabbitMQ.
0 Comments
Leave a Reply. |