// 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 SendAMQ { public class Program { private const string SERVER = "tcp://localhost:61616"; private const string UN = "arne"; private const string PW = "topsecret"; private const string QNAME = "TestQ"; private const string PAYLOAD = "\r\n 123\r\n ABC\r\n"; public static void Main(string[] args) { IConnectionFactory confac = new ConnectionFactory(new Uri(SERVER)); using(IConnection con = confac.CreateConnection(UN, PW)) { con.Start(); using(ISession ses = con.CreateSession(AcknowledgementMode.AutoAcknowledge)) { using(IQueue q = ses.GetQueue(QNAME)) { using(IMessageProducer sender = ses.CreateProducer(q)) { for(int i = 0; i < 3; i++) { IMessage smsg = ses.CreateTextMessage(PAYLOAD); sender.Send(smsg); } } } } } } } }