1

Context

I have a RedisMqServer configured to handle a single message on my ServiceStack web service. The messages on that MQ originate from another application and show up in the .inq with all the correct properties. Everything is on 4.0.38.

My configuration in MyAppHost.cs:

public override void Configure(Container container)
{
    var redisFactory = new PooledRedisClientManager(0, "etc:etc");
    redisFactory.ConnectTimeout = 5;
    redisFactory.IdleTimeOutSecs = 30;
    redisFactory.PoolTimeout = 3;
    container.Register<IRedisClientsManager>(redisFactory);

    //Plugins, Filters, other Registrations omitted

    var mqHost = new RedisMqServer(redisFactory, retryCount: 2);
    mqHost.DisablePublishingResponses = true;
    mqHost.RegisterHandler<CreateVisitor>(ServiceController.ExecuteMessage);
    mqHost.Start();
}

And then in Global.asax.cs:

void Application_Start(object sender, EventArgs e)
{
    new MyAppHost().Init();
}

Problem

The messages are not consistently handled when I deploy this elsewhere. They wait in the .inq until whenever. Nothing is lost, just delayed for an indeterminate duration.

As of this moment, the only things that come to mind are:

  1. I'm using IIS Express locally, and the server is using IIS.
  2. Application_Start needs to happen before it can handle messages.

I've tried initializing the service by making other API calls over HTTP, before and after queuing messages, with more failure than success. Sometimes the service starts to handle them, but I am unable to identify and thus influence when this happens.

Note

I do have several other console applications and windows services that listen on other MQs and handle messages placed by other applications, and those have always worked flawlessly. This is the first time I've tried this from within an existing web service, however.

Facio Ratio
  • 3,373
  • 1
  • 16
  • 18

1 Answers1

1

Hard to know what the issue from this description (are messages getting lost or just delayed?) but this sounds like it's due to ASP.NET AppDomain recycling in which case you can disable AppDomain recycling or setup up a continuous ping route to hit your ASP.NET Web Application to keep the AppDomain alive.

If the ASP.NET Service is available on the Internet you can use services like https://uptimerobot.com or https://www.pingdom.com to configure it to ping your Service at different intervals (e.g. 5-10 minutes) otherwise if this is an internal Service you can use a Scheduled Task.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • Message handling is delayed, not lost. I do have some success with recycling the app pool and then pinging the service; the next message usually then triggers the handler. I can't seem to find a sequence that works 100% of the time... – Facio Ratio Mar 26 '15 at 20:19
  • After recycling the app pool and pinging my service, I am unable to reproduce my original problem. I had been renaming web.config to web.config2 and back to restart the application, and then pinging the service, but that was not working before. (Now it does.) Perhaps I shall never know. – Facio Ratio Mar 26 '15 at 20:30