We have an Azure Web Role that needs to monitor a Service Bus Queue for responses to earlier requests (which will then be transmitted to the client via SignalR).
At first we wanted to use a message pump (QueueClient.OnMessage) in the WebRole.OnStart(). However, we have grown to quite like the WebJobs SDK, especially how it frees the programmer of some lower level implementation and the dashboard too.
For various reasons we want to keep the Web Role rather than switch to a WebSite. So a question arises: how to use the WebJobs SDK in an Azure Web Role? In a little experiment we have adapted the Web Role's OnStart() in WebRole.cs, as follows:
public class WebRole : RoleEntryPoint
{
public override bool OnStart()
{
JobHostConfiguration config = new JobHostConfiguration()
{
ServiceBusConnectionString = "...",
StorageConnectionString = "...",
DashboardConnectionString = "..."
};
JobHost host = new JobHost(config);
host.RunAndBlock();
return base.OnStart();
}
public static void ProcessQueueMessage([ServiceBusTrigger("MyQueue")] string inputText)
{
Trace.WriteLine(inputText);
}
}
This seems to work fine, but we're having difficulty to assess the impact it has on the Web Role. Could there be consequences? Perhaps in scaling the Web Role?
Thanks.