// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using Apache.NMS; using Apache.NMS.ActiveMQ; namespace Tx.NonXAMQ { public class Good : MQ { public override IConnection GetConnection() { IConnectionFactory cf = new ConnectionFactory(new Uri("tcp://localhost:61616")); IConnection con = cf.CreateConnection(); con.Start(); return con; } public override void Test() { for(int i = 0; i < 10; i++) { using(IConnection con = GetConnection()) { using(ISession ses = con.CreateSession(AcknowledgementMode.AutoAcknowledge)) { using(IQueue qin = ses.GetQueue("Qin"), qout = ses.GetQueue("Qout")) { using(IMessageConsumer receiver = ses.CreateConsumer(qin)) using(IMessageProducer sender = ses.CreateProducer(qout)) { IMessage msg = receiver.Receive(); sender.Send(msg); } } } } } } public static void Main(string[] args) { Demo(new Good()); Console.ReadKey(); } } }