ActiveMQ NMS Fails when User/Password Required

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

ActiveMQ NMS Fails when User/Password Required

pwalter
ActiveMQ NMS fails when User/Password is required. ActiveMQ with JAVA works with same URL/user/pwd.

                Uri connecturi = new Uri(url);
                IConnectionFactory factory = new Apache.NMS.ActiveMQ.ConnectionFactory(connecturi);

                connection = factory.CreateConnection(user, password);
                connection.Start();

Error: Apache.NMS.ActiveMQ.ConnectionClosedException: The connection is already closed!

Any Ideas ??
THANKS FOR YOUR QUICK RESPONSE!!!
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ NMS Fails when User/Password Required

pwalter
I downloaded the "most recent" NMS ActiveMQ (1.6.2) and got this error after running the code:

System.IO.IOException was unhandled by user code
  HResult=-2146232800
  Message=The operation is not allowed on non-connected sockets.
  Source=System
  StackTrace:
       at System.Net.Sockets.NetworkStream.InitNetworkStream(Socket socket, FileAccess Access)
       at System.Net.Sockets.NetworkStream..ctor(Socket socket)
       at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransport.CreateSocketStream()
       at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransport.Start()
       at Apache.NMS.ActiveMQ.Transport.TransportFilter.Start()
       at Apache.NMS.ActiveMQ.Transport.TransportFilter.Start()
       at Apache.NMS.ActiveMQ.Transport.WireFormatNegotiator.Start()
       at Apache.NMS.ActiveMQ.Transport.TransportFilter.Start()
       at Apache.NMS.ActiveMQ.Transport.TransportFilter.Start()
       at Apache.NMS.ActiveMQ.Connection.CheckConnected()
       at Apache.NMS.ActiveMQ.Connection.Start()
       at FdsMessaging.ConnectionActiveMQ.createConnection() in xxxxxxx

The operation mentioned in error above is connection.Start();

THANKS!!
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ NMS Fails when User/Password Required

Jim Gomes
In reply to this post by pwalter
This code works, and it is used frequently.  Following is a snippet from my
own code.  I recommend staying at the generic NMS API level, and not using
ActiveMQ provider specific APIs.  You will have much greater portability
success between different NMS providers.

IConnectionFactory cf = new NMSConnectionFactory(providerURLs,
connectionID);
IConnection connection = cf.CreateConnection(userName, password);


Best,
Jim



On Thu, Jun 5, 2014 at 10:55 AM, pwalter <[hidden email]> wrote:

> ActiveMQ NMS fails when User/Password is required. ActiveMQ with JAVA works
> with same URL/user/pwd.
>
>                 Uri connecturi = new Uri(url);
>                 IConnectionFactory factory = new
> Apache.NMS.ActiveMQ.ConnectionFactory(connecturi);
>
>                 connection = factory.CreateConnection(user, password);
>                 connection.Start();
>
> Error: Apache.NMS.ActiveMQ.ConnectionClosedException: The connection is
> already closed!
>
> Any Ideas ??
> THANKS FOR YOUR QUICK RESPONSE!!!
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-NMS-Fails-when-User-Password-Required-tp4681728.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ NMS Fails when User/Password Required

pwalter
Jim,
Thanks...
What do you use for the connectionID? Will null work?
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ NMS Fails when User/Password Required

Jim Gomes
I use the following template and use variable replacement at runtime:

${appname}-${hostname}-${guid}

This way I can look in the connections list in the ActiveMQ broker console
and know where the connection came from, but it gets a unique ID so that
more than one instance of the app on the same machine will show up as a
distinct connection.



On Thu, Jun 5, 2014 at 12:02 PM, pwalter <[hidden email]> wrote:

> Jim,
> Thanks...
> What do you use for the connectionID? Will null work?
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-NMS-Fails-when-User-Password-Required-tp4681728p4681735.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>