Exemple #1
0
        public WorkerHandle ConnectWorkerFabric(string typeID, int count, RequestUpdateHandler updateHandler, RequestCompleteHandler completeHandler)
        {
            // ### the count is just an estimate of the clients expected workload

            // the returned object contains the offset for the queue this client will use
            // if there's an existing queue that meets this requirement, return that detail
            // if not, create and bind it, then return that detail

            ComputeFarm.ComputeRequest req = new ComputeFarm.ComputeRequest("WorkerRequest", typeID, count);
            openRequests.Add(req);
            controlQueue.PostMessage(req.commandString, thisClientID + ".farmRequest.proxy");

            if (WaitForAck(req))
            {
                SetupWorkerQueue(typeID);
                Queue workerQueue = workerQueues[FindWorkerQueue(typeID)];
                workerQueue.SetListenerCallback(WorkerCallback);

                RequestUpdateEvent   += updateHandler;
                RequestCompleteEvent += completeHandler;

                return(new WorkerHandle(workerQueue, typeID));
            }
            return(null);
        }
Exemple #2
0
 internal void SetupControlQueue()
 {
     try
     {
         ConnectionDetail ctrlConn = baseConn.Update(new ConnectionDetail("", "", -1, "", "", ControlBaseName, thisClientID + ".farmResponse.farm", "", "", ""));
         controlQueue = new Queue(baseExchange, ctrlConn);
         controlQueue.SetListenerCallback(CommandCallback);
         ComputeFarm.ComputeRequest req = new ComputeFarm.ComputeRequest("Init");
         openRequests.Add(req);
         controlQueue.PostMessage(req.commandString, thisClientID + ".farmRequest.proxy");
         if (!WaitForAck(req))
         {
             controlQueue = null;
         }
     }
     catch (Exception e)
     {
     }
 }