Added priority queue design pattern (#888)

* added priority queue design pattern

* Minor Refactored, fixed review comments
This commit is contained in:
Ranjeet
2019-08-31 23:40:35 +05:30
committed by Ilkka Seppälä
parent 11c0550559
commit 7f6067f19f
10 changed files with 616 additions and 7 deletions

27
priority-queue/README.md Normal file
View File

@ -0,0 +1,27 @@
---
layout: pattern
title: Priority Queue Pattern
folder: priority-queue
permalink: /patterns/priority-queue/
categories: Behavioral
tags:
- Java
- Difficulty-Beginner
---
## Intent
Prioritize requests sent to services so that requests with a higher priority are received and processed more quickly than those of a lower priority. This pattern is useful in applications that offer different service level guarantees to individual clients.
## Explanation
Applications may delegate specific tasks to other services; for example, to perform background processing or to integrate with other applications or services. In the cloud, a message queue is typically used to delegate tasks to background processing. In many cases the order in which requests are received by a service is not important. However, in some cases it may be necessary to prioritize specific requests. These requests should be processed earlier than others of a lower priority that may have been sent previously by the application.
## Applicability
Use the Property pattern when
* The system must handle multiple tasks that might have different priorities.
* Different users or tenants should be served with different priority..
## Real world examples
* [ Priority Queue Pattern](https://docs.microsoft.com/en-us/previous-versions/msp-n-p/dn589794(v=pandp.10))
Microsoft Azure does not provide a queuing mechanism that natively support automatic prioritization of messages through sorting. However, it does provide Azure Service Bus topics and subscriptions, which support a queuing mechanism that provides message filtering, together with a wide range of flexible capabilities that make it ideal for use in almost all priority queue implementations.