![]() Generally there are two types of messages in MassTransit: Events and Commands, and in this case your message is Event. Make sure that your consumers implements IConsumer interface with the same generic type.Rabbit.Host(new Uri("rabbitmq://localhost:5672"), settings => ![]() Private static void RunMassTransitReceiver() Receiver Management console app : namespace ISendEndpoint sendEndpoint = sendEndpointTask.Result Ĭ.FaultAddress = new Uri("rabbitmq://localhost:5672/accounting/") Task sendEndpointTask = rabbitBusControl.GetSendEndpoint(new Uri(string.Concat(rabbitMqAddress, "/", rabbitMqQueue))) IBusControl rabbitBusControl = (rabbit => Uri rabbitMqRootUri = new Uri(rabbitMqAddress) String rabbitMqAddress = "rabbitmq://localhost:5672" ![]() Private static void RunMassTransitPublisher() Publisher Console App : namespace Masstransit.PublisherĬonsole.WriteLine("CUSTOMER REGISTRATION COMMAND PUBLISHER") When we publish message to exchange it will send copy of message to each queue and eventually received by each consumer services. We can achieve it by having separate queue for each consumer services and each queue bind with a single exchange. Note, the Environment.MachineName gives the unique queue name for each instance TO THIS: cfg.ReceiveEndpoint(host, Environment.MachineName, queueConfigurator => Return (configurator =>Ĭonfigurator.Host(new Uri("rabbitmq://localhost:5671"), host =>Ĭonfigurator.Message(x => ) ĪND EACH CONSUMERS SERVICE instance config relevant lines of code changed FROM: cfg.ReceiveEndpoint(host, "my.exchange", exchangeConfigurator =>ĮxchangeConfigurator.ExchangeType = "topic" MessageCorrelation.UseCorrelationId(x => x.CorrelationId) Publisher Service is configured as follows: builder.Register(context => I want ALL instances to consume the same message. The first one to consume the message takes it off the queue and the rest of the service instances don't get to consume it. NET core consumer service steal messages from the others. NET Core 2.1 Service Consuming those messages.Īt the moment competing instances of the. NET 4.5.2 Service Publishing messages to RabbitMq via MassTransit.Īnd multiple instances of a.
0 Comments
Leave a Reply. |