Japs.Core 0.6.0

dotnet add package Japs.Core --version 0.6.0
                    
NuGet\Install-Package Japs.Core -Version 0.6.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Japs.Core" Version="0.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Japs.Core" Version="0.6.0" />
                    
Directory.Packages.props
<PackageReference Include="Japs.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Japs.Core --version 0.6.0
                    
#r "nuget: Japs.Core, 0.6.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Japs.Core@0.6.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Japs.Core&version=0.6.0
                    
Install as a Cake Addin
#tool nuget:?package=Japs.Core&version=0.6.0
                    
Install as a Cake Tool

JustAnotherPersistentScheduler (JAPS)

A lightweight, persistent task scheduler for .NET applications with support for multiple storage backends.

Features

  • 🚀 Persistent task scheduling - Tasks survive application restarts
  • 🔄 Multiple execution attempts - Configurable retry mechanism with exponential backoff
  • 💾 Multiple storage backends - Memory and SQL Server providers included
  • 🎯 Type-safe task definitions - Strongly typed task handlers and parameters
  • High performance - Optimized for concurrent execution
  • 🔒 Race condition safe - Atomic task locking prevents duplicate execution
  • 🏗️ Dependency injection ready - Full integration with .NET DI container

Quick Start

1. Install NuGet packages

# Core package
dotnet add package Japs.Core

# SQL Server provider (optional)
dotnet add package Japs.Core.SqlServer

2. Register services

// Program.cs
builder.Services
    .AddJaps()  // Core services
    .AddJapsSqlServer(new JapsSqlServerConfiguration 
    {
        ConnectionString = "your-connection-string"
    });

// Or use memory storage for development
builder.Services
    .AddJaps()  // Core services only (uses memory storage)

3. Create a task handler

public class SendEmailTask
{
    public string To { get; set; }
    public string Subject { get; set; }
    public string Body { get; set; }
}

public class SendEmailHandler : ISchedulerTaskHandler<SendEmailTask>
{
    private readonly IEmailService _emailService;
    
    public SendEmailHandler(IEmailService emailService)
    {
        _emailService = emailService;
    }
    
    public async Task Handle(ScheduledTask scheduledTask, SendEmailTask parameter)
    {
        await _emailService.SendAsync(parameter.To, parameter.Subject, parameter.Body);
    }
}

4. Schedule tasks

public class OrderController : ControllerBase
{
    private readonly IScheduler _scheduler;
    
    public OrderController(IScheduler scheduler)
    {
        _scheduler = scheduler;
    }
    
    [HttpPost]
    public async Task<IActionResult> CreateOrder(CreateOrderRequest request)
    {
        // Process order...
        
        // Schedule confirmation email to be sent in 5 minutes
        await _scheduler.Add(
            SchedulerTaskFactory.From<SendEmailHandler, SendEmailTask>(
                taskKey: $"order-confirmation-{orderId}",
                executeAt: DateTime.UtcNow.AddMinutes(5),
                parameter: new SendEmailTask
                {
                    To = request.Email,
                    Subject = "Order Confirmation",
                    Body = $"Your order #{orderId} has been confirmed"
                }
            ));
            
        return Ok();
    }
}

5. Start the background service

// Program.cs
builder.Services.AddHostedService<SchedulerBackgroundService>();

Advanced Usage

Task Creation Methods

// 1. Basic scheduling
await scheduler.Add(SchedulerTaskFactory.From<Handler, Parameter>(
    "task-key", executeAt, parameter));

// 2. With group key for batch operations
await scheduler.Add(SchedulerTaskFactory.From<Handler, Parameter>(
    "task-key", "group-key", executeAt, parameter));

// 3. With retry configuration
await scheduler.Add(SchedulerTaskFactory.From<Handler, Parameter>(
    "task-key", executeAt, parameter, retryCount: 5));

// 4. Immediate execution
await scheduler.Add(SchedulerTaskFactory.FromNow<Handler, Parameter>(
    "task-key", parameter));

// 5. Delayed execution
await scheduler.Add(SchedulerTaskFactory.FromDelay<Handler, Parameter>(
    "task-key", TimeSpan.FromHours(1), parameter));

Task Management

// Remove specific task
await scheduler.RemoveByTaskKey("task-key");

// Remove all tasks in a group
await scheduler.RemoveByGroupKey("group-key");

// Remove by unique identifier
await scheduler.RemoveByPK(taskId);

Error Handling

Tasks that throw exceptions are automatically retried based on the configured retry count. Failed tasks are logged with full error details including stack traces.

public async Task Handle(ScheduledTask scheduledTask, MyTask parameter)
{
    try
    {
        // Your task logic here
        await ProcessTask(parameter);
    }
    catch (TemporaryException ex)
    {
        // This will trigger a retry (if retries remaining)
        throw;
    }
    catch (PermanentException ex)
    {
        // Log and don't retry
        _logger.LogError(ex, "Permanent failure processing task");
        return; // Don't throw - task will be marked as completed
    }
}

Configuration

SQL Server Provider

services.AddJapsSqlServer(new JapsSqlServerConfiguration
{
    ConnectionString = "Server=...;Database=...;",
    TableName = "ScheduledTasks" // Optional, default: "ScheduledTasks"
});

Background Service Options

services.Configure<JapsConfiguration>(options =>
{
    options.CheckIntervalInMilliseconds = 5000; // Default: 5 seconds
});

Architecture

JAPS uses a race-condition-free approach to task execution:

  1. GetTasksIds() - Quickly retrieves IDs of tasks ready for execution
  2. GetAndLockTask() - Atomically locks and retrieves individual tasks
  3. Parallel processing - Multiple scheduler instances can run safely

This design ensures that each task is executed exactly once, even in multi-instance deployments.

Requirements

  • .NET 6.0 or later
  • SQL Server (when using SqlServer provider)

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Japs.Core:

Package Downloads
Japs.Core.SqlServer

Japs - JustAnotherPersistentScheduler SQL Server provider for persistent task scheduling

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.0 185 9/1/2025
0.5.0 723 2/18/2022
0.4.4 653 2/18/2022
0.4.3 629 2/18/2022
0.4.2 637 2/14/2022
0.4.1 663 2/14/2022
0.4.0 644 2/13/2022
0.3.0 650 2/13/2022
0.2.2 639 2/13/2022
0.2.1 636 2/13/2022
0.2.0 636 2/13/2022
0.1.5 647 2/13/2022
0.1.4 653 2/13/2022
0.1.3 653 2/12/2022
0.1.2 648 2/12/2022
0.1.1 535 2/12/2022
0.1.0 777 2/12/2022