Вопрос

I am trying use topic based routing through easynetQ. In my setup i have 3 queues("A.B", "A.C","B.C") and exchange "ex". All three queues are connected to "ex" with routing keys "A.B","A.C","B.C".

Below is my code.

       var bus = RabbitHutch.CreateBus(MQConnectionString).Advanced;
        var exchange = Exchange.DeclareTopic("ex");

        using (var publishChannel = bus.OpenPublishChannel())
        {
            Message pat = new Message();
            while (i++ < 10)
            {
                pat.Name = "Vamsee-" + i;
                pat.ID = Guid.NewGuid().ToString();
                if(i%3==0)
                publishChannel.Publish(exchange, "A.*", new Message<Message>(pat));
                else
                publishChannel.Publish(exchange, "A.C", new Message<Message>(pat));
            }
        }

Here when my code publishes to "A." , the message is not going to all (or) any of the queues. I have tried ".*", "#" either

Please suggest

Thanks Vamsee

Это было полезно?

Решение

You have this the wrong way round. You need to publish each message with a full routing key. The queues can be bound with wild cards or with specific binding keys in order that they will receive the correct messages. If you include the code for your consumer it might be easier to diagnose the problem more precisely

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top