For the complete documentation index, see llms.txt. This page is also available as Markdown.

Aws Scheduler

Reference · Applies to Brighter V10

AWS EventBridge Scheduler is a fully managed, serverless service on AWS that allows you to create, run, and manage scheduled tasks at scale. Brighter integrates with AWS EventBridge Scheduler to provide cloud-native scheduling for AWS workloads.

When to Use AWS Scheduler

AWS Scheduler is recommended when:

  • Running on AWS: Your application is deployed on AWS (EC2, ECS, Lambda, etc.)

  • Serverless Architecture: You prefer managed services over self-hosted solutions

  • AWS Native: You want to leverage AWS services directly

  • Scalability: You need to handle millions of scheduled messages

  • Cost Optimization: You want to pay per use without managing infrastructure

  • Multi-Region: You need to schedule across AWS regions

When NOT to use:

  • Multi-Cloud: Need scheduler to work across cloud providers

  • On-Premises: Application runs outside AWS

  • Complex Scheduling: Need advanced scheduling features (job chains, dependencies)

  • Dashboard: Need visual management interface

How Brighter Integrates with AWS Scheduler

Brighter provides two approaches for scheduling with AWS EventBridge Scheduler:

When UseMessageTopicAsTarget = true (default), Brighter schedules messages directly to the target SNS topic or SQS queue:

Benefits:

  • Fewer moving parts

  • Lower latency (no intermediate handler)

  • Simpler architecture

2. Via FireAwsScheduler Message

When UseMessageTopicAsTarget = false or using request scheduler, Brighter schedules through an intermediate FireAwsScheduler message:

Use when:

  • Request scheduling (Send/Publish commands, not messages)

  • Target topic doesn't exist at scheduling time

  • Need centralized scheduler message handling

IAM Role Requirements

AWS EventBridge Scheduler requires an IAM role that allows it to publish to SNS topics and send messages to SQS queues.

Trust Policy

The role must trust the EventBridge Scheduler service:

Permissions Policy

The role must have permissions to publish messages:

Best Practice: Limit Resource to specific topic/queue ARNs instead of "*".

Automatic Role Creation

Brighter can create the role automatically if it doesn't exist:

Options:

  • OnMissingRole.Assume (default): Assume role exists, throw error if not found

  • OnMissingRole.Create: Create role if it doesn't exist

AWS Scheduler NuGet Packages

AWS Scheduler integration is available in two versions:

Uses the latest AWS SDK for .NET v4.

AWS SDK v3 (Legacy)

Uses AWS SDK for .NET v3 (deprecated in AWS).

Recommendation: Use V4 for new projects. Both packages provide identical Brighter functionality.

AWS Scheduler Configuration

AWS Scheduler Factory Options

AwsSchedulerFactory takes the AWS connection and the IAM role as constructor arguments and exposes the rest as properties. The surface is the same in both packages: AWS and AWS.V4 declare the same ten options with the same defaults, and differ only in the AWS SDK they bind.

Option
Type
Default
Description

TimeProvider

TimeProvider

TimeProvider.System

The clock the scheduler measures delays against.

Group

SchedulerGroup

a new SchedulerGroup

The EventBridge Scheduler group Brighter creates schedules in.

GetOrCreateMessageSchedulerId

Func<Message, string>

a fresh identifier per message

Names the schedule Brighter creates for a message.

GetOrCreateRequestSchedulerId

Func<IRequest, string>

a fresh identifier per request

Names the schedule Brighter creates for a request.

FlexibleTimeWindowMinutes

int?

null

The window, in minutes, within which AWS may run the schedule; the schedule runs at its exact time when this is null.

SchedulerTopicOrQueue

RoutingKey

empty

Names the topic or queue FireAwsScheduler messages are published to.

Role

string

none

Names the IAM role, as a role name or an ARN, that EventBridge Scheduler assumes to deliver the message.

UseMessageTopicAsTarget

bool

true

Targets the message's own topic or queue directly rather than routing through a FireAwsScheduler message.

OnConflict

OnSchedulerConflict

Throw

What Brighter does when a schedule with the same identifier already exists.

MakeRole

OnMissingRole

Assume

What the factory does about the IAM role before it schedules.

Role is a constructor argument rather than a property with a default, so every factory names a role. OnSchedulerConflict is Throw or Overwrite; OnMissingRole is Assume, Validate or Create, and Automatic Role Creation covers the last of them.

AWS Scheduler Group Options

Group takes a SchedulerGroup, which carries three options of its own.

Option
Type
Default
Description

Name

string

"default"

Names the EventBridge Scheduler group the schedules belong to.

Tags

List<Tag>

one tag, Source = Brighter

The tags Brighter applies to the group when it creates it.

MakeSchedulerGroup

OnMissingSchedulerGroup

Assume

What the factory does when the group does not exist.

Basic Configuration

Configure AWS Scheduler with minimal settings:

Configuration with Dispatcher (FireAwsScheduler Handler)

If using FireAwsScheduler approach, configure the Dispatcher to handle scheduler messages:

Configuration with Scheduler Groups

AWS EventBridge Scheduler supports organizing schedules into groups:

Options:

  • OnMissingSchedulerGroup.Assume (default): Assume group exists

  • OnMissingSchedulerGroup.Create: Create group if it doesn't exist

Configuration with Flexible Time Window

EventBridge Scheduler supports flexible time windows for cost optimization:

A flexible time window allows AWS to batch executions for better efficiency. The schedule will execute within the specified window after the scheduled time.

Configuration with Custom Scheduler ID

Customize how Brighter generates scheduler IDs for messages and requests:

Use Cases:

  • Idempotency: Same ID prevents duplicate schedules

  • Tracking: Correlate scheduled tasks with business entities

  • Debugging: Meaningful IDs in AWS Console

AWS Scheduler Code Examples

Basic Scheduling with Delay

Schedule a command to execute after a delay:

Scheduling with Absolute Time

Schedule for a specific time:

Cancelling a Scheduled Job

Cancel a scheduled task before it executes:

Publishing Events with Delay

Schedule an event to be published:

Scheduling Modes Comparison

Feature
Direct to Target
Via FireAwsScheduler

Configuration

UseMessageTopicAsTarget = true

UseMessageTopicAsTarget = false

Use Case

Message scheduling

Request scheduling

Latency

Lower (direct)

Higher (2-hop)

Components

Fewer

More (requires Dispatcher)

Flexibility

Target must exist

More flexible

Recommended For

Production messages

Requests and commands

UseMessageTopicAsTarget defaults to true, so a factory schedules direct to target unless you say otherwise — see AWS Scheduler Factory Options.

AWS Scheduler Best Practices

1. Use Direct to Target for Messages

2. Limit IAM Role Permissions

3. Use Scheduler Groups for Organization

4. Handle OnConflict Appropriately

5. Use Custom Scheduler IDs for Idempotency

6. Monitor AWS Scheduler Metrics

7. Use Flexible Time Windows for Cost Optimization

8. Test with LocalStack

AWS Scheduler Troubleshooting

Schedules Not Executing

Symptom: Schedules created but never fire

Possible Causes:

  1. IAM role missing or incorrect permissions

  2. Target topic/queue doesn't exist

  3. Schedule created in wrong region

  4. FireAwsScheduler handler not configured

Solutions:

Access Denied Errors

Symptom: AccessDeniedException when creating schedules

Cause: Application credentials lack EventBridge Scheduler permissions

Solution:

Schedule Conflicts

Symptom: ConflictException when creating schedule

Cause: Schedule with same ID already exists

Solutions:

High Costs

Symptom: Unexpected AWS Scheduler costs

Causes:

  • Too many one-time schedules created and not cleaned up

  • Short polling intervals

Solutions:

AWS Scheduler Summary

AWS EventBridge Scheduler is a cloud-native, serverless scheduling solution perfect for:

  • AWS Workloads - Native integration with AWS services

  • Serverless Applications - No infrastructure to manage

  • High Scalability - Millions of schedules supported

  • Cost Optimization - Pay only for what you use

Recommended for production when running on AWS infrastructure. Consider Quartz.NET or Hangfire for multi-cloud or on-premises deployments.

Key Decision Factors:

  • ✅ Use AWS Scheduler if: Running on AWS, prefer managed services, need scalability

  • ✅ Use Quartz if: Multi-cloud, complex scheduling, need job clustering

  • ✅ Use Hangfire if: Need dashboard, simple setup, OK without strong naming

  • ✅ Use InMemory if: Testing only, not for production

Last updated

Was this helpful?