using System;
using Apache.NMS;
using Apache.NMS.Util;
using Apache.NMS.ActiveMQ;
using Apache.NMS.ActiveMQ.Commands;
namespace TestActiveMQ
{
class Program
{
static void Main(string[] args)
{
IConnectionFactory factory = new ConnectionFactory("tcp://localhost:61616/");
using (IConnection connection = factory.CreateConnection())
{
connection.ClientId = "MYID";
connection.Start();
using (ISession session = connection.CreateSession())
{
IMessageConsumer consumer = session.CreateConsumer(new ActiveMQQueue("px_contracts_update"), null, false);
consumer.Listener += consumer_Listener;
Console.ReadLine();
}
connection.Stop();
}
}
private static void consumer_Listener(IMessage message)
{
Console.WriteLine("Got: " + ((ITextMessage)message).Text);
}
}
}
Advertisement