-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgraded Sample to use the latest Quartz integration
- Loading branch information
Showing
9 changed files
with
72 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/QuartzService/CancelScheduledMessageConsumerDefinition.cs
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
src/QuartzService/MassTransitQuartzRegistrationExtensions.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
namespace QuartzService; | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using MassTransit; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
|
||
public class SuperWorker : | ||
BackgroundService | ||
{ | ||
readonly IMessageScheduler _messageScheduler; | ||
|
||
public SuperWorker(IMessageScheduler messageScheduler) | ||
{ | ||
_messageScheduler = messageScheduler; | ||
} | ||
|
||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
await _messageScheduler.SchedulePublish(TimeSpan.FromSeconds(15), new DemoMessage() { Value = "Hello, World" }, cancellationToken: stoppingToken); | ||
} | ||
} | ||
|
||
|
||
public class DemoMessage | ||
{ | ||
public string Value { get; set; } | ||
} | ||
|
||
|
||
public class SampleConsumer : | ||
IConsumer<DemoMessage> | ||
{ | ||
readonly ILogger<SampleConsumer> _logger; | ||
|
||
public SampleConsumer(ILogger<SampleConsumer> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public Task Consume(ConsumeContext<DemoMessage> context) | ||
{ | ||
_logger.LogInformation("Received scheduled message: {Value}", context.Message.Value); | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |