Unable to get Topic Exchange to Work in RabbitMQ AMQP 1.0

1.1k views Asked by At

I am finding it very difficult to work with RabbitMQ and AMQP 1.0, particularly as it pertains to topic exchanges using AMQPNetLite. I am unable to send a message using a topic exchange to a specific queue. I'm not even using wildcards.

My situation is super simple too. I have one topic exchange. I have one queue that the topic exchange sends to. When I send to the topic exchange, the queue never receives the message.

test.exchange:
  bind: testqueue - routing key: test

testqueue:
  bound to exchange with routing key: test

The AMQP 1.0 documentation says that the "Subject" is the routing key right? Well when I use AMQPNetLite to send to RabbitMQ, it appears to connect, and the topic appears to have received the message, but it is never routed to the queue.

Here's the entire code:

            var rabbitMqAddress = $"amqp://127.0.0.1:5672";
            var address = new Address(rabbitMqAddress);
            var producerName = $"Producer-test.topic-{Time.GetTimeStamp()}";

            var connection = new Connection(address, null, new Open
            {
                ContainerId = Guid.NewGuid().ToString(),
                ChannelMax = 64,
            }, null);

            var session = new Session(connection);
            var senderLink = new SenderLink(session, producerName, "/topic/test.exchange");

            senderLink.Send(new Message
            {
                BodySection = new AmqpValue { Value = "test 123" },
                Properties = new Properties
                {
                    Subject = "test",
                }
            });

enter image description here

The image proves the binding. Is there something I'm missing?

1

There are 1 answers

1
ThorHalvor On BEST ANSWER

i think you mix two ways of doing it. Either you publish to address "/topic/test" -where test is your routingkey OR you publish to "/exchange/test.exchange" and set the Subject-property to "test".

Both works. if you use the "/topic/"-prefix in your address you are going through the default "amq.topic"-exchange and not your own "test-exchange".

made sense? more information in the "Routing and Addressing"-secion here: https://github.com/rabbitmq/rabbitmq-amqp1.0