Skip to content

Instantly share code, notes, and snippets.

@budiadiono
Forked from davidfowl/gist:3950404
Created December 13, 2012 09:38
Show Gist options
  • Save budiadiono/4275294 to your computer and use it in GitHub Desktop.
Save budiadiono/4275294 to your computer and use it in GitHub Desktop.
private static int GetRoleInstanceNumber()
{
var roleInstanceId = RoleEnvironment.CurrentRoleInstance.Id;
var li1 = roleInstanceId.LastIndexOf(".");
var li2 = roleInstanceId.LastIndexOf("_");
var roleInstanceNo = roleInstanceId.Substring(Math.Max(li1, li2) + 1);
return Int32.Parse(roleInstanceNo);
}
string connectionString = // Your connection string
int numTopics = 2;
int instanceCount = 2;
int instanceId = GetRoleInstanceNumber();
string topicPrefix = "MyApplicationName";
GlobalHost.DependencyResolver.UseServiceBus(
connectionString,
numTopics,
instanceCount,
instanceId,
topicPrefix
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment