static void Main(string[] args)
        {
            try
            {
                Producer p = new Producer();
                JMSProxy jms = new JMSProxy();
                jms.CreateTopicConnection(BROKER_HOST, BROKER_PORT, TOPIC,
                                     BROKER_USERID, BROKER_PASSWORD, false);
                jms.CreateTopicProducer();

                String msg = Console.ReadLine();
                while (!msg.Equals("END"))
                {
                    if (msg.StartsWith("file:"))
                    {
                         StreamReader rdr = new StreamReader(msg.Substring(5));
                         msg = rdr.ReadToEnd();
                         rdr.Close();
                    }
                    jms.SendMessage(msg);
                    msg = Console.ReadLine();
                }

                jms.SendMessage("END");
                jms.DestroyTopicProducer();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
        static void Main(string[] args)
        {
            try
            {
                Consumer p = new Consumer();
                bool doAsync = false;

                if ( args.Length == 1 && !String.IsNullOrEmpty(args[0]) )
                {
                    try
                    {
                        doAsync = Convert.ToBoolean(args[0]);
                    }
                    catch (FormatException fe)
                    {
                        Console.WriteLine("Unrecognized boolean value (" + fe.Message + ") : " + args[0]);
                    }
                }

                JMSProxy jms = new JMSProxy();
                jms.CreateTopicConnection(BROKER_HOST, BROKER_PORT, TOPIC,
                                     BROKER_USERID, BROKER_PASSWORD, doAsync);

                if (doAsync)
                {
                    Console.WriteLine("Starting ASYNC Consumer");
                    jms.CreateTopicConsumerAsync(p.ProcessMessageDelegateAsync);
                    bool stop = false;
                    Console.WriteLine("==>Enter 'q' to quit");
                    do
                    {
                        stop = Console.Read() == 'q';
                    } while (!stop);
                }
                else
                {
                    Console.WriteLine("Starting SYNC Consumer");
                    jms.CreateTopicConsumerSync();
                    Console.WriteLine("==>Send (from producer) 'END' to quit");
                    // this is a blocking call so it won't return until we are ready to shutdown
                    jms.ConsumeTopicMessages(p.MessageHandler);
                }

                jms.DestroyTopicConsumer();

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }