Exemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();

            EventMessageFactory factory = new EventMessageFactory();

            factory.CreateSubscription("CriticalEventsMonitor", "0"); // 0 is critical priority per the data generator
            subscription   = factory.CreateSubscriptionClient("CriticalEventsMonitor");
            btnListen.Text = "Don't Listen";
            subscription.StartListener(message => this.UpdateUI(message.GetBody <EventMessage>().Message));
        }
Exemplo n.º 2
0
        public override void Run()
        {
            // This is a sample worker implementation. Replace with your logic.
            Trace.WriteLine("EventPoint_WorkerRole entry point called", "Information");

            EventMessageFactory factory = new EventMessageFactory();

            factory.CreateSubscription("AllEventsWorkerRole"); // no filter, all events
            subscription = factory.CreateSubscriptionClient("AllEventsWorkerRole");

            // using listener extension methods provided by Microsoft.Samples.ServiceBusMessaging
            subscription.StartListener(message => WriteToAzureTable(message));

            while (true)
            {
                Thread.Sleep(2000);
            }
        }
Exemplo n.º 3
0
        public override void Run()
        {
            Trace.WriteLine("CriticalPersister entry point called", "Information");

            EventMessageFactory factory = new EventMessageFactory();

            factory.CreateSubscription("CriticalEventsPersister", "0"); // 0 is critical priority per the data generator
            subscription = factory.CreateSubscriptionClient("CriticalEventsPersister");

            eventService = new CriticalEventService();

            // using listener extension methods provided by Microsoft.Samples.ServiceBusMessaging
            subscription.StartListener(message => Publish(message));

            while (true)
            {
                Thread.Sleep(2000);
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.Title = "EventPoint Console";

            Console.WriteLine("This is an on-prem console application that receives critical alerts");
            Console.WriteLine("multi-cast through the Azure AppFabric ServiceBus.");
            Console.WriteLine("");

            EventMessageFactory factory = new EventMessageFactory();

            factory.CreateSubscription("CriticalEventsConsole", "0"); // 0 is critical priority per the data generator
            SubscriptionClient subscription = factory.CreateSubscriptionClient("CriticalEventsConsole");

            Console.WriteLine("Ready....");

            // Demostrates listening via polling Topic
            while (true)
            {
                BrokeredMessage message = subscription.Receive(TimeSpan.FromSeconds(10));
                if (message != null)
                {
                    try
                    {
                        EventMessage evtMsg = message.GetBody <EventMessage>();
                        Console.WriteLine(String.Format("[{0}] {1}", DateTime.Now.ToLongTimeString(), evtMsg.Message));
                        message.Complete();
                    }
                    catch (Exception)
                    {
                        message.Abandon();
                    }
                    finally
                    {
                        message.Dispose();
                    }
                }
            }
        }