Comments (2)
hey @haayman-imagem I realise this is an old issue, but I had a chance for a deep dive of this the other day and wanted to document the results here.
there are two main ways to deal with priorities in a queuing system:
- priority by the type of message (per your goal)
- priority by the metadata of the message (eg customer value ranking)
The approaches for each are quite different. For a message type priority, multiple queues may be used which subscribe to different topics depending on the priority. When fetching messages, messages from the priority queue are read first and if empty then messages in the standard queue are read.
There're a number of issues with this. Firstly most transports don't provide a way to accurately tell if a queue is empty without explicitly reading from it. This library favours long polling of queues as it provides the cheapest cost (for managed queues) and better performance. The only way to truely service this scenario would be to continuously short poll both queues in priority order that could end up being quite costly for things like SQS in a distributed system and also incur a performance hit if the priority queue is constantly empty but having to be called prior to the standard queue being read.
For this type of approach, it's probably better to spin up a separate worker service that only handles high priority messages according to the needs of your app.
For a metadata-based priority system, some transports like RabbitMQ do support publishing messages with a priority that will be read before lower priority messages. It's a very loosely-defined AMQP spec that's in no way prescriptive nor universally supported by all queues.
This is the ideal approach that also supersedes the first approach, but as it is a transport-level feature that's only supported for some transports, it's not something that can be added directly into @node-ts/bus-core
. I also want to avoid an abstraction leak of exposing transport-specific features at the application level; however there's probably a good trade-off to be had between exposing these type of useful features at the cost of being tied in to a transport.
tldr - priorities aren't tough, aren't universally supported by all transports. if there's enough 👍 support then this might be implemented by exposing elements of the transport at the app layer.
from bus.
This has come up a couple of times over the past year and has been solved by creating a separate priority service with its own queue. This works well in the case where certain message types need priority over others; but the real case for priority messages is where there's priority across message types based on eg a high value customer etc whose messages need to be processed before others.
The former case, which is the target of this issue, won't be implemented but priority messages is something that may come down later on.
from bus.
Related Issues (20)
- Errors thrown in workflows aren't visible
- Add workflow lifecycle hooks
- Provide a CLI option for queue migrations
- Construct workflows using container during mapping
- Port middleware over to master HOT 1
- RabbitMQ queue and exchange setup HOT 8
- The memory-queue is inappropriately deleting messages HOT 1
- Broken links in docs HOT 1
- Delay a retry by X seconds HOT 1
- Vulnerability in url-parse - dependency of amqplib HOT 1
- Rabbitmq transport polling HOT 2
- IoC with loopback HOT 4
- Named export <nameExport> not found HOT 2
- [bus-class-serializer]: package.json missing attributes HOT 1
- [Bug] Rabbitmq-transport.ts does not have reconnection if channel gets disconnected by some reasons
- How to setup DI container, when workflow needs the bus instance HOT 2
- Open to update `bus-sqs` to aws-sdk v3?
- Support Mognodb Persistence for Workflows
- RabbitMQ transport doesn't allow custom message headers. HOT 4
- Problem with lodash and persisting workflow state
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bus.