On Wed, 2009-11-18 at 14:20 -0800, gtsafas wrote:
> I am not understanding why this isn't writing to file
> 
> using System;
> using System.IO;
> using System.Collections.Generic;
> using System.Text;
> using Apache.NMS.ActiveMQ;
> using Apache.NMS;
> using Apache.NMS.Util;
> using System.Threading;
> 
> namespace WindowsAuthenticator
> {
>     class Authenticator
>     {
>         protected static ITextMessage message = null;
>         protected static string message2 = null;
> 
>         static void Main(string[] args)
>         {
> 
>             Console.WriteLine("Enter Server");
>             string server = Console.ReadLine();
>             Console.WriteLine("Enter Port");
>             string port = Console.ReadLine();
>             Console.WriteLine("Q or T IE: queue://gt.test or
> topic://gt.test");
>             string qort = Console.ReadLine();
> 
>             Authenticator authen = new Authenticator(server, port, qort);
> 
>         }
> 
>         Authenticator(string uri, string port, string qt)
>         {
>             try
>             {
>                 Uri connecturi = new Uri("tcp://" + uri + ":" + port +
> "?wireFormat=openwire");
>                 Apache.NMS.ActiveMQ.ConnectionFactory factory = new
> ConnectionFactory(connecturi);
>                 IConnection connection = factory.CreateConnection();
>                 ISession session = connection.CreateSession();
> 
>                 IDestination destination =
> SessionUtil.GetDestination(session, qt);
>                 Console.WriteLine("Using destination: " + destination);
> 
>                 IMessageConsumer consumer =
> session.CreateConsumer(destination);
>                 connection.Start();
>                 consumer.Listener += new MessageListener(OnMessage);
> 
>                 Thread.Sleep(100000);
>             }
> 
>             catch (Apache.NMS.NMSConnectionException e)
>             {
>                 Console.WriteLine(e.Message);
>             }
>         }
> 
>         protected static void OnMessage(IMessage receivedMsg)
>         {
>           
>             string filename =
> "C:\\"+DateTime.Now.Year+DateTime.Now.Month+"_AMQSESSION.log";
>             StreamWriter writeFile = new StreamWriter(filename, true);
>             
>             message = receivedMsg as ITextMessage;
>             Console.WriteLine(message.Text);
>             writeFile.Write(message.Text);
>         }
>     }
> }
> 
> 

I'd try adding a call to writeFile.Close() in there to ensure the
buffered data makes it to the file.

Regards
Tim.


-- 
Tim Bish
http://fusesource.com
http://timbish.blogspot.com/



Reply via email to