0

I have used EventProcessorHost for listen azure event hub. I have created an async method in a class for RegisterEventProcessorAsync with event hub configuration . and using this async method in my Startup.cs class . It is working fine on local but while deployed it on Azure its not working . This is my method for register event hub and startup.cs class.

    public static class ProcesssRTS
{
    private static string EhConnectionString =""
    private static string EhEntityPath =""
    private static string StorageContainerName =""
    private static string StorageAccountName =""
    private static string StorageAccountKey =""

    private static readonly string StorageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", StorageAccountName, StorageAccountKey);

    public static async Task MainAsync()
    {
        Console.WriteLine("Registering EventProcessor...");

        var eventProcessorHost = new EventProcessorHost(
            EhEntityPath,
            PartitionReceiver.DefaultConsumerGroupName,
            EhConnectionString,
            StorageConnectionString,
            StorageContainerName);

        await eventProcessorHost.RegisterEventProcessorAsync<RTSEventProcessor>();

        Console.WriteLine("Receiving. Press ENTER to stop worker.");
        Console.ReadLine();
        await eventProcessorHost.UnregisterEventProcessorAsync();
    }
}

 public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        ProcesssRTS.MainAsync();
        app.Map("/signalr", map =>
        {
            map.UseCors(CorsOptions.AllowAll);
            var hubConfiguration = new HubConfiguration { };
            map.RunSignalR(hubConfiguration);
        });

    }
}
amethianil
  • 480
  • 2
  • 7
  • 16
  • I guess you shouldn't use console.readline() and also you should find a way to have this task running all the time and release it if the application stop or restart. you sould have a look at this answer https://stackoverflow.com/a/26264914/4167200. There are also some frameowrk like hangfire that can help: https://www.hangfire.io/ – Thomas Mar 31 '18 at 12:00
  • Thanks @Thomas. not working after removing console.readline() . checking QueueBackgroundWorkItem – amethianil Mar 31 '18 at 12:27
  • Yeah it a little bit of rework to make this think working properly – Thomas Mar 31 '18 at 12:32
  • @Thomas As far as I read other forums, people are suggesting not to use this approach. I am also facing similar issues where the solution is working on my machine but when setup on Azure, it is not working. I found that we have another option called Worker Role but not sure about its usage. Do you have any suggestions? – Anil C Mar 31 '18 at 13:12
  • you have a web app on azure ? you can use a webjob. Depends it you want to have this process inside you web api or not – Thomas Mar 31 '18 at 21:22

0 Answers0