示例#1
0
        public async Task SendTestRequestsAsync()
        {
            // Wait for 2 seconds before beginning.
            await Task.Delay(2 * 1000);

            using (MessageQueue outQ = MqHelper.GetQ(INPUT_Q_PATH, QueueAccessMode.Send, null, null))
            {
                //bool testASI = outQ.DefaultPropertiesToSend.AttachSenderId;

                outQ.Send(CreateJobRequest(0));

                //await Task.Delay(2 * 1000);
                //outQ.Send(CreateJobRequestOV(1));

                //await Task.Delay(2 * 1000);
                //outQ.Send(FJobRequest.CreateGetHistogramRequest(0));



                //await Task.Delay(45 * 1000);
                //outQ.Send(FJobRequest.CreateDeleteRequest(0, deleteRepo:false));
                //outQ.Send(CreateJobRequest(1));
            }

            return;
        }
示例#2
0
        private void SendHistogram(FHistorgram fHistorgram, string requestMsgId)
        {
            using (MessageQueue outQ = MqHelper.GetQ(OUTPUT_HIST_Q_PATH, QueueAccessMode.Send, null, null))
            {
                Message r = new Message(fHistorgram)
                {
                    CorrelationId = requestMsgId
                };

                Console.WriteLine($"Sending a Histogram response message with corId = {requestMsgId}.");
                outQ.Send(r);
            }
        }
示例#3
0
        private void SendFCoordsResult(FCoordsResult fCoordsResult, string requestMsgId)
        {
            using (MessageQueue outQ = MqHelper.GetQ(OUTPUT_COORDS_Q_PATH, QueueAccessMode.Send, null, null))
            {
                Message r = new Message(fCoordsResult)
                {
                    CorrelationId = requestMsgId
                };

                Console.WriteLine($"Sending a Coords response message with corId = {requestMsgId}.");
                outQ.Send(r);
            }
        }
示例#4
0
        public async Task HandleJobs(CancellationToken cToken)
        {
            //HandleJobResponses(m.Id, cToken);

            _outQ = MqHelper.GetQ(OUTPUT_Q_PATH, QueueAccessMode.Send, null, null);

            Task t1 = Task.Run(() => SendProcessor(_sendQueue, _outQ, _cts.Token), _cts.Token);

            _subJobProcessors = new SubJobProcessor[NUM_THREADS];
            for (int wpCntr = 0; wpCntr < NUM_THREADS; wpCntr++)
            {
                _subJobProcessors[wpCntr] = new SubJobProcessor(_workQueue, _sendQueue, wpCntr);
                _subJobProcessors[wpCntr].Start();
            }

            _jobReplayProcessor = new JobReplayProcessor(_replayWorkQueue, _sendQueue);
            _jobReplayProcessor.Start();

            Task t2 = Task.Run(() => ProcessJobs(_workQueue, _cts.Token), _cts.Token);

            Type[] rTtypes            = new Type[] { typeof(FJobRequest) };
            MessagePropertyFilter mpf = new MessagePropertyFilter
            {
                Body          = true,
                Id            = true,
                CorrelationId = true
            };

            using (MessageQueue inQ = MqHelper.GetQ(INPUT_Q_PATH, QueueAccessMode.Receive, rTtypes, mpf))
            {
                while (!cToken.IsCancellationRequested)
                {
                    Message m = await MqHelper.ReceiveMessageAsync(inQ, WaitDuration);

                    if (cToken.IsCancellationRequested)
                    {
                        break;
                    }

                    if (m != null)
                    {
                        Debug.WriteLine("Received a request message.");
                        FJobRequest jobRequest  = null;
                        string      requestType = "Unknown";

                        try
                        {
                            jobRequest  = (FJobRequest)m.Body;
                            requestType = jobRequest.RequestType.ToString();
                            Debug.WriteLine($"The message type is {requestType}. JobId: {jobRequest.JobId}.");
                            HandleRequestMessage(jobRequest, m.Id);
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine($"Got an exception while processing a FJobRequest message of type {requestType}. The error is {e.Message}.");
                        }
                    }
                    else
                    {
                        Debug.WriteLine("No request message present.");
                    }
                }
            }

            Debug.WriteLine("Worker thread ending, starting cleanup routine.");
            Cleanup();
        }