i create windows forms program listening on azure service bus queue , executes long process each received brokeredmessage :
queueclient client = queueclient.createfromconnectionstring(configurationwrapper.queueconnectionstring, configurationwrapper.queuename); // configure callback options onmessageoptions options = new onmessageoptions(); options.autocomplete = false; options.autorenewtimeout = timespan.fromminutes(1); // callback handle received messages client.onmessageasync((message) => { message.complete(); //big jobs put 10 minutes task t = task.factory.startnew(() => doaverylongjob(message)); return t; }, options);
if send 2 messages 2 seconds of interval in queue, program process first message (calling doaverylongjob takes 10 minutes) , second message processed @ end of the first call (10 minutes after). want these messages processed in parallel.
is possible process queue messages in parallel?
in onmessageoptions instance need increase maxconcurrentcalls. following code process 5 messages queue in parallel.
// configure callback options onmessageoptions options = new onmessageoptions(); options.autocomplete = false; options.maxconcurrentcalls = 5; options.autorenewtimeout = timespan.fromminutes(1);
Comments
Post a Comment