NServiceBus + RabbitMq = Scheduled Tasks failing

I am currently testing out nsb7 on .net core, hosting it on linux containers in Pivotal Cloud Foundry.

One of the requirements I have is to have a scheduled task running every x minutes. While testing it locally, it works fine and continues to fire the task every interval.

When I deploy the app to PCF however, the scheduled task runs fine for a while, then just stops firing. The only thing I see in my events is this information.

NServiceBus.DefaultScheduler Could not find any scheduled task with id e77ae92b-d880-4d16-b49d-69961b2b2011. The DefaultScheduler does not persist tasks between restarts.

This is the last information I see before it stops working. Able to reproduce this every time. I don’t know what this information means and how to work around this issue.

Hi

The built-in scheduler is not appropriate for tasks that need to execute reliably in defined intervals as scheduled tasks are not persistent. See the limitations section for details.

If your requirements are relatively simple (e.g. execute every 5 minutes) the best solution would be to use a never-ending saga. Such a saga would have a timeout handler that executes the business logic and, at the end, requests another timeout. The saga never calls MarkAsComplete so it is never removed.

Bear in mind that when not using transactions that span queue and data (e.g. MSMQ/SQL Server/DTC), the messages (including timeout messages) can get duplicated on the way and delivered more than once so your timeout handler logic needs to account for that.

If the requirements around scheduling are more complex you can take a look at our scheduling samples which show how to integrate NServiceBus with various dedicated scheduling solutions.

Hope it helps,
Szymon

Thanks. My requirements took into account the limitations you mentioned, but if it’s not a reliable solution then I’ll look into alternatives like Quartz and try to integrate with NSB.

Oddly enough I just updated to 7.0.0-beta0012 and so far I’ve not seen it stop working.

Here is a sample using quartz.net together with NServiceBus

Cheers,

Andreas