Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var    bus  = AzureBusInitializer.CreateBus("TestPublisher", x => { });
            string text = "";

            while (text != "quit")
            {
                Console.Write("Enter number of messages to generate (quit to exit): ");
                text = Console.ReadLine();

                int numMessages = 0;
                if (int.TryParse(text, out numMessages) && numMessages > 0)
                {
                    Parallel.For(0, numMessages, i =>
                    {
                        var message = new SomethingHappenedMessage()
                        {
                            What = "message " + i.ToString(), When = DateTime.Now
                        };
                        bus.Publish <SomethingHappened>(message, x => { x.SetDeliveryMode(MassTransit.DeliveryMode.Persistent); });
                    });
                }
                else if (text != "quit")
                {
                    Console.WriteLine("\"" + text + "\" is not a number.");
                }
            }

            bus.Dispose();
        }
Exemplo n.º 2
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            bool result = base.OnStart();

            if (result)
            {
                _bus = AzureBusInitializer.CreateBus("TestCloudSubscriber", sbc =>
                {
                    sbc.SetConcurrentConsumerLimit(64);
                    sbc.Subscribe(subs =>
                    {
                        subs.Consumer <SomethingHappenedConsumer>().Permanent();
                    });
                });
            }

            Trace.TraceInformation("TestCloudSubscriberWorker has been started");

            return(result);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var bus = AzureBusInitializer.CreateBus("TestSubscriber", sbc =>
            {
                sbc.SetConcurrentConsumerLimit(64);
                sbc.Subscribe(subs =>
                {
                    subs.Consumer <SomethingHappenedConsumer>().Permanent();
                });
            });

            Console.ReadKey();

            bus.Dispose();
        }