Example #1
0
        static void Main(string[] args)
        {
            Bus bus = new BusBuilder().Configure(ctx => ctx.WithDefaultSerializationStrategy(new JsonSerializationStrategy())).Build();
            bus.Connect();

            bool readingInput = true;
            while(readingInput)
            {
                Console.WriteLine("Press enter to publish a message or 'X' to exit");

                var keyInfo = Console.ReadKey();

                switch(keyInfo.Key)
                {
                    case ConsoleKey.Enter:
                        bus.Publish(new StatusMessage("This is a test."));
                        break;

                        case ConsoleKey.X:
                        readingInput = false;
                        break;
                }
            }

            bus.Close();
        }
Example #2
0
        static void Main(string[] args)
        {
            Bus bus = new BusBuilder().Build();
            bus.Connect();

            bool readingInput = true;
            while (readingInput)
            {
                Console.WriteLine("Press enter to publish a message or 'X' to exit");

                var keyInfo = Console.ReadKey();

                switch (keyInfo.Key)
                {
                    case ConsoleKey.Enter:
                        string messageText = "Hello, World";
                        bus.Publish(new Message(messageText));
                        Console.WriteLine("Published message: {0}", messageText);
                        break;

                    case ConsoleKey.X:
                        readingInput = false;
                        break;
                }
            }

            bus.Close();
        }
Example #3
0
 static void TestRabbitBus(int messageCount)
 {
     Bus bus = new BusBuilder()
         .Configure(ctx => ctx.Publish<TestMessage>().WithExchange("rabbitBus.test.exchange"))
         .Build();
     bus.Connect();
     for (int i = 0; i < messageCount; i++)
     {
         bus.Publish(new TestMessage("test"));
     }
     bus.Close();
 }