protected void processRequest(string queueName, RestRequest request)
        {
            if (!QueuesQueries.QueueExists(DBConnection, queueName))
            {
                throw new QueueNotExistsException();
            }
            else
            {
                var queue    = QueuesQueries.getQueueByName(DBConnection, queueName);
                var worker   = WorkerQueries.GetWorkerById(DBConnection, queue.Worker);
                var coworker = WorkerQueries.GetWorkerById(DBConnection, queue.Cooperator);

                PropageteRequestToWorkers(request, queue, worker, coworker);
            }
        }
Example #2
0
        public Message Get(GetMessage request)
        {
            var requestToSend = new RestRequest($"queues/{request.QueueName}/messages", Method.GET);

            if (!QueuesQueries.QueueExists(DBConnection, request.QueueName))
            {
                throw new QueueNotExistsException();
            }
            else
            {
                var queue    = QueuesQueries.getQueueByName(DBConnection, request.QueueName);
                var worker   = WorkerQueries.GetWorkerById(DBConnection, queue.Worker);
                var coworker = WorkerQueries.GetWorkerById(DBConnection, queue.Cooperator);

                return(PropageteRequestToWorkers <Message>(requestToSend, queue, worker, coworker));
            }
        }
Example #3
0
        public void Delete(DeleteQueue request)
        {
            var requestToSend = new RestRequest($"queues/{request.QueueName}", Method.DELETE);

            if (!QueuesQueries.QueueExists(DBConnection, request.QueueName))
            {
                throw new QueueNotExistsException();
            }
            else
            {
                var queue    = QueuesQueries.getQueueByName(DBConnection, request.QueueName);
                var worker   = WorkerQueries.GetWorkerById(DBConnection, queue.Worker);
                var coworker = WorkerQueries.GetWorkerById(DBConnection, queue.Cooperator);

                QueuesQueries.DeleteQueue(DBConnection, request.QueueName);
                PropageteRequestToWorkers(requestToSend, queue, worker, coworker);
            }
        }
Example #4
0
        public void Create(CreateQueue request)
        {
            var requestToSend = new RestRequest("queues", Method.POST);

            requestToSend.AddParameter("Name", request.Name);

            if (QueuesQueries.QueueExists(DBConnection, request.Name))
            {
                throw new QueueAlreadyExistsException();
            }
            else
            {
                Worker worker, coworker;
                CalculateQueueWorkers(request.Name, out worker, out coworker);
                var queue = QueuesQueries.CreateQueue(DBConnection, request.Name, worker.Id, coworker.Id);
                PropageteRequestToWorkers(requestToSend, queue, worker, coworker);
            }
        }