Ejemplo n.º 1
0
 public static void Sub()
 {
     Console.WriteLine("===> START of Simple Subscriber sample for WMQ transport <===\n");
     Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
     {
         e.Cancel = true;
         SimpleSubscriber.keepRunning = false;
     };
     try
     {
         SimpleSubscriber simpleSubscriber = new SimpleSubscriber();
         if (simpleSubscriber.EnvironmentIsSet())
         {
             simpleSubscriber.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 Subscriber sample for WMQ transport <===\n\n");
 }
Ejemplo n.º 2
0
        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;
                }
            }
        }