I am using Background Jobs as it allows one to execute jobs on a timer, but don’t want to use SQLite but want to let the background jobs be published to an Azure Servicebus queue instead and be processed like normal MQ Messages with failures going to the dlq inside servicebus.
Our code look like :
public class ProcessScheduledReportsCommand(IMessageService MessageService)
: Service, IAsyncCommand<ProcesscheduledReportsRequest>
{
public async Task ExecuteAsync(ProcesscheduledReportsRequest request)
{
using var mqClient = MessageService.MessageFactory.CreateMessageProducer();
Console.WriteLine("queued message");
mqClient.Publish(new ProcessReportSchedulerBackgroundJob());
}
}
public class ProcesscheduledReportsRequest { }
It publishes to the ServiceBus MQ Inqueue, but if you raise an error it writes it to the sqlite dead letter queue instead of Servicebus dlq.
It is not clear from the documentation how to do that. Please help.
I’m confused, Background Jobs is only designed to specifically work with SQLite.
If you’re referring to ServiceStack MQ this is a completely separate and isolated feature and implementation.
I’m not sure what “sqlite dead letter queue” is referring to because there is no Background MQ for SQLite or any other RDBMS.
The other thing that’s weird about this class is that it inherits Service and implements IAsyncCommand? Is this a Service or a Command, if it’s a command what’s executing it?
We have a use case where we need to publish messages to a message queue on a schedule. E.g. once per minute or once per hour etc. It seems as if Background commands are the only way to call code on a schedule at the moment using Servicestack. So we have other instances where we are using MQ Services, and we just did not want to have two different implementations (One for Background Jobs, and one for Background Services).
Can you possible point us in the right direction. Do we use an external library like Hangfire ?