public void Run() { MQSeries mq = new MQSeries(this.queueName, this.queueManagerName, this.host, this.channel, this.port); while (true) { string receivedMsg = mq.GetMessageOffQueue(); if (!receivedMsg.Equals("")) { Thread.Sleep(this.getPollingTimeMillisecs); } } }
public void Run() { MQSeries mq = new MQSeries(this.queueName, this.replyQueueName, this.queueManagerName, this.host, this.channel, this.port); for (int i = 0; i < this.iterations; i++) { mq.PutMessageOnQueue("TEST MESSAGE"); numMsgs++; Thread.Sleep(this.putSleepTimeMillisecs); } }
static void Main(string[] args) { //create a new MSMQ implementation object IMessageQueue msmq = new MSMQ("QueueA"); //bind the implementation to the MessageQueueManager IMessageQueueManager mqm = new MessageQueueManager(msmq); //create a new message object Message m = new Message(); m.Label = "test"; m.Content = "this is test"; try { mqm.OpenConnection(); mqm.SendMessage(m); Message retrievedMessage = mqm.RetrieveMessage(); //send two more method the queue for MessageArrival event test later mqm.SendMessage(m); mqm.SendMessage(m); } finally { mqm.CloseConnection(); } //register the client with the message arrive mqm.RegisterMessageArrivalHanlder(new MessageArrivalHandler(RecieveMessage)); //create a new MQSeries implementation IMessageQueue mqseries = new MQSeries("QueueB"); //bind implementation object to the MessageQueueManager mqm = new MessageQueueManager(mqseries); try { mqm.OpenConnection(); mqm.SendMessage(m); Message retrievedMessage = mqm.RetrieveMessage(); } finally { mqm.CloseConnection(); } Console.ReadLine(); }