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)); }
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); } }
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); } }
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(); } } } }