Reputation: 5114
I'm using Apache ActiveMQ to integrate my app to a custom service. I need to make this run always, not one time like it's right now. The code below works, but only for one message, I need to maintain the connection active in order to receive all the messages.
using (var connection = (Apache.NMS.ActiveMQ.Connection)factory.CreateConnection())
{
connection.UserName = Username;
connection.Password = Password;
using (var session = connection.CreateSession())
{
IDestination destination = SessionUtil.GetDestination(session, "queue://" + Queue);
using (IMessageConsumer consumer = session.CreateConsumer(destination))
//using (IMessageConsumer consumer = session.CreateDurableConsumer(new ActiveMQTopic(Queue), "fpapp", null, false))
{
consumer.Listener += ConsumerOnListener;
connection.Start();
}
}
}
I did some research and found out I should create a durable consumer, and that's what I tried (commented line). But it doesn't work, it says network connections can't subscribe to topics.
Any ideas?
PS: I'm completely new to ActiveMQ.
Thanks
Upvotes: 0
Views: 1591
Reputation: 84
Please take the connection object out of using block. It will do. In C# API normal connection is durable, in STOMP one have to set heartbeat.
Upvotes: 1