rebusrebus-rabbitmq

Identify rebus workers


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?


Solution

  • 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....