/// <summary> /// 接收消息的订阅事件 /// </summary> /// <param name="message"></param> private void consumer_Listener(IMessage message) { if (OnActiveMQReciveMsg != null) { ActiveMQInfo info = new ActiveMQInfo(); if (message.NMSDestination.IsTemporary) { info.Name = ((Apache.NMS.ActiveMQ.Commands.ActiveMQTempDestination)message.NMSDestination).PhysicalName; } else { info.Name = ((Apache.NMS.ActiveMQ.Commands.ActiveMQDestination)message.NMSDestination).PhysicalName; } info.IsQueue = message.NMSDestination.IsQueue; info.IsTopic = message.NMSDestination.IsTopic; info.IsTemporary = message.NMSDestination.IsTemporary; info.MessageId = message.NMSMessageId; info.MQType = (enumActiveMQDestinationType)((int)message.NMSDestination.DestinationType); info.Priority = (enumActiveMQPriority)((int)message.NMSPriority); info.Timestamp = message.NMSTimestamp; info.Type = message.NMSType; info.Message = ((ITextMessage)message).Text; OnActiveMQReciveMsg(info); } }
private void reciver_OnActiveMQReciveMsg(ActiveMQInfo info) { Action action = delegate() { this.richText_ReciveMQ.Text = string.Format("{0}\r\n", info.Name + "_" + info.Message) + this.richText_ReciveMQ.Text; }; if (!this.InvokeRequired) { action.Invoke(); } else { this.BeginInvoke(action); } }