i working on solution webjob monitors service bus queue. works great needs adaptable manage number of queues changing list of queues in config.
currently can see can this:
public static void processqueuemessage1([servicebustrigger("queue1")] brokeredmessage message, textwriter log) { }
and queue need add method:
public static void processqueuemessage2([servicebustrigger("queue2")] brokeredmessage message, textwriter log) { }
obviously, don't want add new method every time need watch new queue.
how go using webjob monitor queue who's name in config? mean list of queue names not 1 in config.
for example, know can use queuenameresolver following:
public static void processqueuemessage([servicebustrigger("%nameincofig%")] brokeredmessage message, textwriter log) {}
but want process list of queue names 1 webjob processqueuemessage method.
i have been searching ages , @ point of using workerrole instead.
any great.
i'm curious why you've got multiple queues being handled same method - there might better design pattern , approach this...but...
you accomplish not using trigger attribute , instead start web job host , use code iterates on queues specified in config file, wiring queue client same onmessage action each one. this:
. . . var factory = messagingfactory.createfromconnectionstring(""); foreach (var queue in queues) { var client = _factory.createqueueclient(queue); client.onmessage(onmessagereceived, options); } . . . public void onmessagereceived(brokeredmessage message) { // work }
there number of additional options on queueclient , onmessage call how messages should handled, approach might work.