// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Messaging; namespace MQR { public class Program { private const string QNAME1 = @".\private$\TestQ1"; private const string QNAME2 = @".\private$\TestQ2"; private const int N = 10; public static void Main(string[] args) { using(MessageQueue q1 = new MessageQueue(QNAME1)) using(MessageQueue q2 = new MessageQueue(QNAME2)) { q1.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) }); q2.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) }); for(int i = 0; i < N; i++) { Message rmsg = q1.Receive(); string s = (string)rmsg.Body; Message smsg = new Message(s + " " + s); q2.Send(smsg); } } } } }