Пример #1
0
 public static bool Start()
 {
     try
     {
         ev = ClonableMessageQueueEvent.GlobalQueue;
         ev.Init();
         mq = ClonableMessageTrunkQuery.GlobalQueue;
         string fullUri = ev.Uri.AbsoluteUri;//"tcp://" + serv.ToString() + ":" + localPort + "/" + service;
         wrapperRemoteObject = new RemoteObjectWrapper();
         wrapperRemoteObject.WrapperBroadcastMessageEvent += new EventHandler <BroadcastEventArgs>(BroadcastEvent_Received);
         broadcast = (BroadcastEvent)Activator.GetObject(typeof(BroadcastEvent), fullUri);
         broadcast.Broadcasting += new EventHandler <BroadcastEventArgs>(wrapperRemoteObject.WrapperBroadMessage);
         Console.WriteLine("初始化订阅型消息服务成功!");
         string fullUri2 = mq.Uri.AbsoluteUri;//"tcp://" + serv.ToString() + ":" + localPort + "/" + service;
         wrapperRemoteObject2 = new RemoteObjectWrapper();
         wrapperRemoteObject2.WrapperBroadcastMessageEvent += new EventHandler <BroadcastEventArgs>(BroadcastEvent2_Received);
         broadcast2 = (BroadcastEvent)Activator.GetObject(typeof(BroadcastEvent), fullUri2);
         broadcast2.Broadcasting += new EventHandler <BroadcastEventArgs>(wrapperRemoteObject2.WrapperBroadMessage);
         Console.WriteLine("初始化消费型消息服务成功!");
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine("开始服务监听失败:" + e.Message);
         Logs.Create("开始服务监听失败:" + e.Message);
         return(false);
     }
 }
Пример #2
0
        /// <summary>
        /// 私人消息队列
        /// </summary>
        public MessageQueueEvent()
        {
            BroadcastEvent be = new BroadcastEvent();

            reg = MessageServer <BroadcastEvent> .Intialize(be, ConfigurationManager.AppSettings["service"], Convert.ToInt32(ConfigurationManager.AppSettings["port"]));

            if (reg.Channels.Count > 0)
            {
                this.channel = reg.Channels[0];//.Find(a => a.ChannelName == ConfigurationManager.AppSettings["service"]);
            }
            be.Channel = this.channel;
            if (reg.Uris.Count > 0)
            {
                this.uri = reg.Uris.Find(a => a.Segments[a.Segments.Length - 1] == ConfigurationManager.AppSettings["service"]);
            }
        }
Пример #3
0
        /// <summary>
        /// 私人消息队列
        /// </summary>
        public ClonableMessageTrunkQuery()
        {
            trunk = new KellPersistence.Trunk <ClonableObject>("KellMQ.ClonableObject");
            messageNotifyEvent  = new Dictionary <Guid, ClonableConsumeEventHandler>();
            messagesNotifyEvent = new Dictionary <Guid, ClonableConsumingEventHandler>();
            BroadcastEvent be = new BroadcastEvent();

            reg = MessageServer <BroadcastEvent> .Intialize(be, ConfigurationManager.AppSettings["service2"], Convert.ToInt32(ConfigurationManager.AppSettings["port2"]));

            if (reg.Channels.Count > 0)
            {
                this.channel = reg.Channels[0];//.Find(a => a.ChannelName == ConfigurationManager.AppSettings["service2"]);
            }
            be.Channel = this.channel;
            if (reg.Uris.Count > 0)
            {
                this.uri = reg.Uris.Find(a => a.Segments[a.Segments.Length - 1] == ConfigurationManager.AppSettings["service2"]);
            }
        }
Пример #4
0
        /// <summary>
        /// 私人消息队列
        /// </summary>
        public MessageQueueQuery()
        {
            messageNotifyEvent  = new Dictionary <Guid, ConsumeEventHandler>();
            messagesNotifyEvent = new Dictionary <Guid, ConsumingEventHandler>();
            List <BaseMessage> oldMsgs = GetAllMessages();

            foreach (BaseMessage msg in oldMsgs)
            {
                this.Add(msg.ID, msg);
            }
            BroadcastEvent be = new BroadcastEvent();

            reg = MessageServer <BroadcastEvent> .Intialize(be, ConfigurationManager.AppSettings["service2"], Convert.ToInt32(ConfigurationManager.AppSettings["port2"]));

            if (reg.Channels.Count > 0)
            {
                this.channel = reg.Channels[0];//.Find(a => a.ChannelName == ConfigurationManager.AppSettings["service2"]);
            }
            be.Channel = this.channel;
            if (reg.Uris.Count > 0)
            {
                this.uri = reg.Uris.Find(a => a.Segments[a.Segments.Length - 1] == ConfigurationManager.AppSettings["service2"]);
            }
        }