R
R
Ruslan2018-11-25 13:50:03
RabbitMQ
Ruslan, 2018-11-25 13:50:03

How to configure MassTransit + RabbitMQ so that multiple consuming threads get all copies of published messages?

Hello!
Can you please tell me how to set up the bus so that every message posted to the queue is received by every consumer. Now I have one process publishing and receiving messages to / from the queue and two processes simply receive messages from the queue and at the same time, each message goes to only one process, i.e. they all take turns processing the message stream. how to make the message be consumed by each process.
I set up the queue like this:

var busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                var host = cfg.Host(new Uri("rabbitmq://localhost/"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                cfg.ReceiveEndpoint(host,"customer_update_queue", ec =>
                {
                    ec.LoadFrom(_instance);
                });
            });

            _instance.RegisterInstance<IBusControl>(busControl);
            _instance.RegisterInstance<IBus>(busControl);

            busControl.Start();

_instance is the Unity IoC container
in other processes, creating and connecting to the bus looks like this:
var busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                var host = cfg.Host(new Uri("rabbitmq://localhost/"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                cfg.ReceiveEndpoint(host, "customer_update_queue", ec =>
                {
                    //ec.Consumer<SmsService>();
                    SmsService s = new SmsService();
                    ec.Instance(s);
                });
            });


            busControl.Start();

Thank you for your attention.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2018-11-25
@inoise

Stop configuring crawl architecture in code. This will not lead to good. Go to their website - there are excellent tutorials. In general, you need an exchange to which several queues are attached

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question