Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have a configuration based queue name for web job processing?

I have a webjob app to process a ServiceBus queue, which runs fine, with the following method:

public static void ProcessQueueMessage([ServiceBusTrigger("myQueueName")] BrokeredMessage message, TextWriter log)

However, I would like to be able to change the queue name without recompiling, according for example to a configuration appsetting, can it be done?

like image 455
Alberto Silva Avatar asked Dec 25 '22 12:12

Alberto Silva


1 Answers

Yes, you can do this. You can implement your own INameResolver and set it on JobHostConfiguration.NameResolver. Then, you can use a queue name like %myqueue% in our ServiceBusTrigger attribute - the runtime will call your INameResolver to resolve that %myqeuue% variable - you can use whatever custom code you want to resolve the name. You could read it from app settings, etc.

like image 161
mathewc Avatar answered Apr 27 '23 22:04

mathewc