2

I'm new to RabbitMQ and trying it out. In my RabbitMQ server, I have set up an Exchange (TestExch) and I've created 2 queues (TestQ and NewQ). I than created bindings from TestExch to the queues with a routing keys (Q1 and Q2).

This is mt c# code that I use to publish messages:

string message = Console.ReadLine();
while(!String.IsNullOrEmpty(message))
{
    counter++;
    byte[] messageBuffer = Encoding.Default.GetBytes(message);

    string q = counter % 2 == 0 ? "Q1" : "Q2";
    model.BasicPublish("TestExch", q, properties, messageBuffer);

    Console.WriteLine(message + " => " + q);
    message = Console.ReadLine();
}

but when I look at the server when I send a message I see that it gets inserted into both queues.

What am I doing wrong?

developer82
  • 13,237
  • 21
  • 88
  • 153

1 Answers1

2

The problem was that the exchange type I defined was fanout - to get the result I was expecting I needed to use the direct option.

developer82
  • 13,237
  • 21
  • 88
  • 153