コード例 #1
0
        public static void StartPolling(IDatabaseHandler dbHandler)
        {
            if (PollContext == null)
            {
                throw new System.Exception("PollContext not set");
            }
            //  Prepare our sockets
            PollerControlIntraComm = PollContext.Socket(SocketType.REP);
            PollerControlIntraComm.Connect("inproc://pollercontrol");

            ActivatorIntraComm = PollContext.Socket(SocketType.REQ);
            ActivatorIntraComm.Connect("inproc://activator");

            PollItem[] Poller = new PollItem[1];
            Poller[0] = PollerControlIntraComm.CreatePollItem(IOMultiPlex.POLLIN);
            Poller[0].PollInHandler += new PollHandler(PollerCTRL_PollInHandler);
            while (!Exit)
            {
                PollContext.Poll(Poller, 5000);
                if (!Stop)
                {
                    //poll
                    //get all available pending workflow instances

                    DataTable dt = dbHandler.GetPendingWFInstances();
                    foreach (DataRow Row in dt.Rows)
                    {
                        //send to kickoff
                        ValkQueueWFMessage Message = new ValkQueueWFMessage();
                        Message.Command      = ValkQueueWFMessage.WFCommand.WFC_LOAD;
                        Message.InstanceID   = int.Parse(Row["WFInstanceID"].ToString());
                        Message.InstanceKey  = Row["InstanceKey"].ToString();
                        Message.InstanceType = Row["WFType"].ToString();
                        ActivatorIntraComm.Send <ValkQueueWFMessage>(Message);
                        string message = ActivatorIntraComm.Recv(Encoding.Unicode);
                        //Console.WriteLine("Instance Insert Reply Received: " + message);
                    }
                }
            }
        }