activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Gomes <e.se...@gmail.com>
Subject Re: C# - NMS.ActiveMQ (Trunk) - Windows-Service with admin-user account
Date Mon, 21 Nov 2011 19:48:52 GMT
This is interesting.  With your work-around in place, it will eventually
connect and everything works correctly after that?

On Mon, Nov 21, 2011 at 8:59 AM, Shine <activemq@club.webhop.org> wrote:

> hi,
>
> I am using the latest version of NMS to connect to an ActiveMQ Server
> (version 5.5).
> If you use this snippet in a windows service runs with a local admin
> credential, you get an EndOfStreamException at "this.connection.Start();".
>
> That snippet works fine in a normal windows application or if the service
> runs with "local system".
>
> Snippet
>
>            try
>            {
>                Apache.NMS.IConnectionFactory connectionFactory = new
> Apache.NMS.ActiveMQ.ConnectionFactory("ssl://xxxxxxxxx");
>
>                System.Diagnostics.Trace.WriteLine("Verbindung wird
> erstellt.");
>                this.connection =
> connectionFactory.CreateConnection("MessageBrokerUsername",
> "MessageBrokerPassword");
>                this.connection.ExceptionListener += new
> Apache.NMS.ExceptionListener(connection_ExceptionListener);
>                // this.connection.ClientId =
> System.Environment.TickCount.ToString();
>
>                System.Diagnostics.Trace.WriteLine("Verbindung wird
> aufgebaut.");
> // !!!! Here occures the exception !!!!
>                this.connection.Start();
>
>                this.session = connection.CreateSession();
>                System.Diagnostics.Trace.WriteLine("Queue wird erstellt.");
>                Apache.NMS.IDestination destination = new
> Apache.NMS.ActiveMQ.Commands.ActiveMQQueue("test");
>
>
>                System.Diagnostics.Trace.WriteLine("Consumer wird
> erstellt.");
>                this.consumer = session.CreateConsumer(destination);
>                this.consumer.Listener += new
> Apache.NMS.MessageListener(consumer_Listener);
>
>            }
>            catch (System.Exception ex)
>            {
>                System.Diagnostics.Trace.WriteLine(ex.ToString());
>            }
>
> Workaround: Call "CreateConnection" and "Start" again.
>
> Replace: this.connection.Start();
> To:
>                bool connected = false;
>                int connectionCounter = 0;
>                while (!connected)
>                {
>                    try
>                    {
>                        connectionCounter++;
>                        this.connection.Start();
>                        connected = this.connection.IsStarted;
>                    }
>                    catch (System.Exception ex)
>                    {
>                        this.connection.Dispose();
>                        System.Diagnostics.Trace.WriteLine(ex.ToString());
>                        System.Diagnostics.Trace.WriteLine("Tries to
> connect: " + connectionCounter.ToString());
>                        System.Threading.Thread.Sleep(3000);
>                        this.connection =
> connectionFactory.CreateConnection("MessageBrokerUsername",
> "MessageBrokerPassword");
>                    }
>                }
>
>
>
> Anyone knows a other solution for my problem?
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/C-NMS-ActiveMQ-Trunk-Windows-Service-with-admin-user-account-tp4092212p4092212.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message