mercredi 8 février 2017

How to limit StackExchange.Redis Subscribe handlers?

Vote count: 0

I am using StackExhange to develop a message queue, I am doing that with the PUB/SUB functionality of the library.

I am doing something like this in my worker code:

 RedisSubscriber.Subscribe(TaskNoticeKey, delegate { HandleWork(); });

What I want is my worker to get notified when work is ready to be processed from the queue, and Handle that work using a delegate (HandleWork) however when multiple tasks are sent to the queue at the same time, the HandleWork method can be called by the same worker in a different thread (The same worker can call HandleWork multiple times each in its own thread).

If I have a small number of workers and send a thousand tasks, each worker tries to process hundreds of tasks on its own, since the handler delegate seems to be called from different threads.

I want to limit how many threads can be created to process work, is there a way to do that?

asked 19 secs ago

Let's block ads! (Why?)



How to limit StackExchange.Redis Subscribe handlers?

Aucun commentaire:

Enregistrer un commentaire