I have an application running ok sending messages to activemq. I'm using spring.net and Nmstemplate to connect to broker. xml configuration file in general is:
<object id="ActiveMqConnectionFactory"
type="Apache.NMS.ActiveMQ.ConnectionFactory, Apache.NMS.ActiveMQ">
</object>
<object id="ConnectionFactory"
type="Spring.Messaging.Nms.Connections.CachingConnectionFactory, Spring.Messaging.Nms">
<constructor-arg index="0" ref="ActiveMqConnectionFactory"/>
<property name="SessionCacheSize" value="10"/>
</object>
<object id="NmsTemplate"
type="Spring.Messaging.Nms.Core.NmsTemplate, Spring.Messaging.Nms">
<constructor-arg index="0" ref="ConnectionFactory"/>
<property name="MessageConverter" ref="SimpleMessageConverter"/>
</object>
<object id="SimpleMessageConverter"
type="Spring.Messaging.Nms.Support.Converter.SimpleMessageConverter, Spring.Messaging.Nms">
</object>
Until everything is working find sending message with NmsTemplate.ConvertAndSend(); The problem is that I want to secure connection using username/password. I setup credentials in activemq configuration file and now I need to supply this credentials in code but I dont find where !! I tried with:
<object id="ActiveMqConnectionFactory" type="Apache.NMS.ActiveMQ.ConnectionFactory, Apache.NMS.ActiveMQ">
<property name="UserName" value="usertest"/>
<property name="Password" value="passwordtest"/>
</object>
But when sending I get "Connection already closed" exception, and the same setting credentials in code.
So, anyone have a good example or hint in how to setup username/password to send message to secured activemq broker?