Monday 15 March 2010

azure - Using the Webjobs SDK in a Web Role -



azure - Using the Webjobs SDK in a Web Role -

we have azure web role needs monitor service bus queue responses before requests (which transmitted client via signalr).

at first wanted utilize message pump (queueclient.onmessage) in webrole.onstart(). however, have grown quite webjobs sdk, how frees programmer of lower level implementation , dashboard too.

for various reasons want maintain web role rather switch website. question arises: how utilize webjobs sdk in azure web role? in little experiment have adapted web role's onstart() in webrole.cs, follows:

class="lang-cs prettyprint-override">public class webrole : roleentrypoint { public override bool onstart() { jobhostconfiguration config = new jobhostconfiguration() { servicebusconnectionstring = "...", storageconnectionstring = "...", dashboardconnectionstring = "..." }; jobhost host = new jobhost(config); host.runandblock(); homecoming base.onstart(); } public static void processqueuemessage([servicebustrigger("myqueue")] string inputtext) { trace.writeline(inputtext); } }

this seems work fine, we're having difficulty assess impact has on web role. there consequences? perhaps in scaling web role?

thanks.

the webjobs sdk should work fine in webrole.

i have 1 suggestion on implementation: not block onstart method. instead of calling runandblock, utilize start/startasync. not block method , create separate thread job host.

the (not sure if compiles):

class="lang-cs prettyprint-override">public class webrole : roleentrypoint { private jobhost host; public override bool onstart() { jobhostconfiguration config = new jobhostconfiguration() { servicebusconnectionstring = "...", storageconnectionstring = "...", dashboardconnectionstring = "..." }; host = new jobhost(config); host.start(); homecoming base.onstart(); } // not sure if signature of onstop // or if method called way public override bool onstop() { host.stop(); homecoming base.onstop(); } public static void processqueuemessage([servicebustrigger("myqueue")] string inputtext) { trace.writeline(inputtext); }

}

azure azure-web-roles azureservicebus azure-webjobssdk

No comments:

Post a Comment