1

I'm using rebus 6.6.4.0, Rebus.RabbitMq 7.3.5.0 I'm trying to identify each thread in messagehandler by their names. I thought that they are always named by default as Rebus 1 worker 1, but in practice I see that many threads doesn't have names and as I understand threads got from thread pool which could have any ManagedThreadId and no name already. In my use case I want to identify one worker to allow it handle the message type while other workers do Failfast. so is there is way to identify rebus workers/threads?

AzizD
  • 103
  • 10

1 Answers1

0

I thought that they are always named by default as Rebus 1 worker 1, but in practice I see that many threads doesn't have names and as I understand threads got from thread pool which could have any ManagedThreadId and no name already.

You're absolutely right: Rebus' worker threads have pretty names, but after the first await (usually when receiving the message from the transport) code will most likely be executed by a thread pool thread, and so the names will no longer by controlled by Rebus.

In my use case I want to identify one worker to allow it handle the message type while other workers do Failfast. so is there is way to identify rebus workers/threads?

Could you tell me more about your use case? Maybe there's a better way to do what you're trying to do....

mookid8000
  • 18,258
  • 2
  • 39
  • 63
  • I've workers handing a message and sending payment messages to provider by providerid. sometimes provider can have problems and message finally fails to the error queue, after a while I revert them back to the main queue, so messages start to get stack on the bus. .... – AzizD Jul 28 '22 at 11:23
  • ... so I count each errors by providers and add the provider to bad list. Each worker while handling the message checks the provider in badlist and is bad failfast the message. But to remove the provider from badlist I need check if the payment could be made. so my idea was to have just one worker that ignores the bad list of providers and tries to handle the message as usual and if ok removes it. to do that I need to somehow identify that worker. – AzizD Jul 28 '22 at 11:23
  • Sounds a little bit like the circuit breaker pattern, only with individual circuit breaker instances for each provider – maybe you should take a look at that? I don't think there's an easy way to do what you're thinking about by differentiating between Rebus' worker threads. – mookid8000 Aug 02 '22 at 05:43
  • 1
    yes, you're right, wanted to do it very simple, but correct way to use circuit breaker pattern. – AzizD Aug 02 '22 at 08:27