Question

I'm sure this is an easy one for anybody with basic knowledge of MT/RMQ.

I've taken a simple client/server example from the web and I am trying to get it working locally on my machine, however I am having no luck. I've got RabbitMQ web management showing that my 'client' messages are being published, however my 'server' isn't picking up those messages.

This is the code I have:

    // Server
class Program
    {
        static void Main(string[] args)
        {
            Console.WindowWidth = 200;
            Console.WriteLine("This is the server");
            Bus.Initialize(sbc =>
            {
                sbc.UseRabbitMq();
                sbc.ReceiveFrom("rabbitmq://localhost/simple_first_server");
                sbc.Subscribe(subs =>
                {
                    subs.Handler<string>(msg => Console.WriteLine(msg));
                });
            });
            Console.ReadKey();
        }
    }

// Client
    class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("This is the client");
                Bus.Initialize(sbc =>
                {
                    sbc.UseRabbitMq();
                    sbc.ReceiveFrom("rabbitmq://localhost/simple_first_server");
                });
                String read;
                while (!String.IsNullOrEmpty(read = Console.ReadLine()))
                {
                    Bus.Instance.Publish("hello");
                }

                Console.ReadKey();
            }
        }

For reference, I am running Windows 8 (64bit). I've not configured Windows in anyway other than installing Erland and RabbitMQ - maybe I have missed an install step?

Thanks for the help

Was it helpful?

Solution

The two programs need to read from different queues. What likely is happening is the client is reading from the queue and discarding the message before the server has the chance to read the message.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top