0
votes

I have long running process running in the message handler, I noticed that I can't read from the table while the task is in process.

Is this ok?

Or is there a better way to handle long running processes?

My transport is SQL Server.

Thanks in advance :)

public class HandlerAwaitsTheTask : IHandleMessages<CommandMessage>
{
    public async Task Handle(CommandMessage message, IMessageHandlerContext context)
    {
        await SomeLibrary.VeryVeryVeryLongTask(message);
    } 
}
1

1 Answers

0
votes

It depends. :-)

How long is "VeryVeryVeryLong"? 2 minutes? 2 hours? 2 days? Which table is being locked? Locking an entire table feels like something is off. It hardly can be the queue, because it should only lock one or a few rows for pulling messages. So it is likely your own table.

Besides that, the lock is probably a serializable lock. Which is likely caused by a distributed transaction. So maybe you're using different connection strings at the least, or different databases for business and NServiceBus data.

It's not like you absolutely cannot have very long tasks and long locks, but depending on how long it is, SQL Server or other things might start complaining. Throughput can also be limited. We probably need more context to see what is happening and what you need.

You can also contact [email protected] for more information and support.