I am creating a worker role using the service bus worker role template.
It is taking more than a minute for me to process each message.
Because of this, i am seeing that the same message is received by the worker role multiple times, roughly one message every minute.
I figured that this is because this value defaults to 60 seconds.
But I am not sure how to increase this value, because i am not seeing the messageFactorySettings class anywhere.
Where do I set this property?
here is the code I am using
public class WorkerRole : RoleEntryPoint
{
// QueueClient is thread-safe. Recommended that you cache
// rather than recreating it on every request
QueueClient Client;
ManualResetEvent CompletedEvent = new ManualResetEvent(false);
public override void Run()
{
Client.OnMessage((receivedMessage) =>
{
ProcessMessage(recievedMessage);
});
CompletedEvent.WaitOne();
}
public override bool OnStart()
{
ServicePointManager.DefaultConnectionLimit = 12;
string connectionString = ConfigurationUtility.GetConnectionString("Microsoft.ServiceBus.ConnectionString");
string queneName = ConfigurationUtility.GetConnectionString("QueueName");
// Create the queue if it does not exist already
var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
if (!namespaceManager.QueueExists(queneName))
{
namespaceManager.CreateQueue(queneName);
}
Client = QueueClient.CreateFromConnectionString(connectionString, queneName);
return base.OnStart();
}
public override void OnStop()
{
// Close the connection to Service Bus Queue
Client.Close();
CompletedEvent.Set();
base.OnStop();
}
}