public static void Get() { Console.WriteLine("===> START of Simple Consumer sample for WMQ transport <===\n"); Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) { e.Cancel = true; SimpleConsumer.keepRunning = false; }; try { SimpleConsumer simpleConsumer = new SimpleConsumer(); if (simpleConsumer.EnvironmentIsSet()) { simpleConsumer.ReceiveMessages(); } } catch (XMSException ex) { Console.WriteLine("XMSException caught: {0}", ex); if (ex.LinkedException != null) { Console.WriteLine("Stack Trace:\n {0}", ex.LinkedException.StackTrace); } Console.WriteLine("Sample execution FAILED!"); } catch (Exception ex) { Console.WriteLine("Exception caught: {0}", ex); Console.WriteLine("Sample execution FAILED!"); } Console.WriteLine("===> END of Simple Consumer sample for WMQ transport <===\n\n"); }
static void Main(string[] args) { String token; if (args.Length < 1) { Console.WriteLine("Say which program you want to run; put, get, pub, sub, request, response"); } else { token = (String)args.GetValue(0); Console.WriteLine(token); switch (token) { case "put": SimpleProducer.Put(); break; case "get": SimpleConsumer.Get(); break; case "sub": SimpleSubscriber.Sub(); break; case "pub": SimplePublisher.Pub(); break; case "request": SimpleRequest.Request(); break; case "response": SimpleResponse.Response(); break; default: Console.WriteLine("Say which program you want to run; put, get, pub, sub, request, response"); break; } } }