@@ -17,12 +17,16 @@ public class SimpleTopicPublisher : IDisposable
1717 private readonly ISession session ;
1818 private readonly IMessageProducer producer ;
1919 private bool isDisposed = false ;
20+
2021
21- public SimpleTopicPublisher ( string topicName , string brokerUri )
22+ public SimpleTopicPublisher ( string topicName , string brokerUri , string UserName , string PassWord )
2223 {
2324 this . topicName = topicName ;
2425 this . connectionFactory = new ConnectionFactory ( brokerUri ) ;
25- this . connection = this . connectionFactory . CreateConnection ( ) ;
26+ if ( UserName == null )
27+ this . connection = this . connectionFactory . CreateConnection ( ) ;
28+ else
29+ this . connection = this . connectionFactory . CreateConnection ( UserName , PassWord ) ;
2630 this . connection . Start ( ) ;
2731 this . session = connection . CreateSession ( ) ;
2832 ActiveMQTopic topic = new ActiveMQTopic ( topicName ) ;
@@ -71,12 +75,17 @@ public class SimpleTopicSubscriber : IDisposable
7175 private bool isDisposed = false ;
7276 public event MessageReceivedDelegate OnMessageReceived ;
7377
74- public SimpleTopicSubscriber ( string topicName , string brokerUri , string clientId , string consumerId , string filter )
78+
79+
80+ public SimpleTopicSubscriber ( string topicName , string brokerUri , string clientId , string consumerId , string filter , string UserName , string PassWord )
7581 {
7682 string ft = filter == null ? null : $ "filter='{ filter } '";
7783 this . topicName = topicName ;
7884 this . connectionFactory = new ConnectionFactory ( brokerUri ) ;
79- this . connection = this . connectionFactory . CreateConnection ( ) ;
85+ if ( UserName == null )
86+ this . connection = this . connectionFactory . CreateConnection ( ) ;
87+ else
88+ this . connection = this . connectionFactory . CreateConnection ( UserName , PassWord ) ;
8089 this . connection . ClientId = clientId ;
8190 this . connection . Start ( ) ;
8291 this . session = connection . CreateSession ( ) ;
@@ -122,11 +131,16 @@ public class SimpleQueueSender : IDisposable
122131 private readonly IMessageProducer producer ;
123132 private string queue_name ;
124133
125- public SimpleQueueSender ( string queueName , string brokerUri , AcknowledgementMode ackmode = AcknowledgementMode . AutoAcknowledge )
134+
135+
136+ public SimpleQueueSender ( string queueName , string brokerUri , string UserName , string PassWord , AcknowledgementMode ackmode = AcknowledgementMode . AutoAcknowledge )
126137 {
127138 this . queue_name = queueName ;
128139 factory = new ConnectionFactory ( brokerUri ) ;
129- connection = factory . CreateConnection ( ) ;
140+ if ( UserName == null )
141+ connection = factory . CreateConnection ( ) ;
142+ else
143+ connection = factory . CreateConnection ( UserName , PassWord ) ;
130144 this . connection . Start ( ) ;
131145 session = connection . CreateSession ( ackmode ) ;
132146 ActiveMQQueue queue = new ActiveMQQueue ( queueName ) ;
@@ -168,11 +182,16 @@ public class SimpleQueueReciever : IDisposable
168182 private readonly IMessageConsumer consumer ;
169183 public event MessageReceivedDelegate OnMessageReceived ;
170184
171- public SimpleQueueReciever ( string queueName , string brokerUri , string clientId , string filter , AcknowledgementMode ackmode = AcknowledgementMode . AutoAcknowledge )
185+
186+
187+ public SimpleQueueReciever ( string queueName , string brokerUri , string clientId , string filter , string UserName , string PassWord , AcknowledgementMode ackmode = AcknowledgementMode . AutoAcknowledge )
172188 {
173189 string ft = filter == null ? null : $ "filter='{ filter } '";
174190 connectionFactory = new ConnectionFactory ( brokerUri ) ;
175- connection = connectionFactory . CreateConnection ( ) ;
191+ if ( UserName == null )
192+ connection = connectionFactory . CreateConnection ( ) ;
193+ else
194+ connection = connectionFactory . CreateConnection ( UserName , PassWord ) ;
176195 connection . ClientId = clientId ;
177196 connection . Start ( ) ;
178197 session = connection . CreateSession ( ackmode ) ;
0 commit comments