InMemoryMQ - doesn't return until after long-running code completed

Hi, I am using in-memory MQ, but it’s not async; MessageFactory.Publish doesn’t return until the long-running code has executed. Is this by design (hence the “Transitory”)?

using (var producer = MessageFactory.CreateMessageProducer())
            var mqRequest = new DeleteUploadRequest();
            mqRequest.UploadId = request.UploadId;
            mqRequest.Session = UserSession;

        return new HttpResult(string.Empty, HttpStatusCode.OK);

Yeah the InMemory MQ is primarily for mocking/testing what are you using it for?

Just want to use MQ within existing infrastructure - i.e. SQL Server + Azure Web app.

Yeah but an InMemory MQ is like having no MQ at all, I.e. you don’t get any of the benefits.

I see that, but was hoping there was some magic implementation that avoided need of Redis Server/SQS (e.g. OrmLite or in-memory queue).

Then it wouldn’t be persistent or distributed, I don’t see the point in using an InMemory MQ other than testing/mocking.

Is purely to avoid the HTTP call lasting as long as the long-running code. I have a db delete that takes 10 minutes.
Not worried about persistence etc due to number of users, just want the code to execute after the http has returned.

You can run it on a background thread, i.e:

ThreadPool.QueueUserWorkItem(_ => { 

Doh - thanks - threading 101. Apologies!

1 Like