public InMemoryOutboxMessageSchedulerContext(MessageSchedulerContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); _scheduledMessages = new List <ScheduledMessage>(); _cancelMessages = new List <Func <Task> >(); }
/// <summary> /// Sends an object as a message, using the type of the message instance. /// </summary> /// <param name="scheduler">The message scheduler</param> /// <param name="message">The message object</param> /// <param name="delay">The time at which the message should be delivered to the queue</param> /// <param name="cancellationToken"></param> /// <returns>The task which is completed once the Send is acknowledged by the broker</returns> public static Task <ScheduledMessage> ScheduleSend(this MessageSchedulerContext scheduler, TimeSpan delay, object message, CancellationToken cancellationToken = default(CancellationToken)) { var scheduledTime = DateTime.UtcNow + delay; return(scheduler.ScheduleSend(scheduledTime, message, cancellationToken)); }
/// <summary> /// Send a message /// </summary> /// <typeparam name="T">The message type</typeparam> /// <param name="scheduler">The message scheduler</param> /// <param name="delay">The time at which the message should be delivered to the queue</param> /// <param name="message">The message</param> /// <param name="cancellationToken"></param> /// <returns>The task which is completed once the Send is acknowledged by the broker</returns> public static Task <ScheduledMessage <T> > ScheduleSend <T>(this MessageSchedulerContext scheduler, TimeSpan delay, T message, CancellationToken cancellationToken = default(CancellationToken)) where T : class { var scheduledTime = DateTime.UtcNow + delay; return(scheduler.ScheduleSend(scheduledTime, message, cancellationToken)); }
/// <summary> /// Sends an interface message, initializing the properties of the interface using the anonymous /// object specified /// </summary> /// <typeparam name="T">The interface type to send</typeparam> /// <param name="scheduler">The message scheduler</param> /// <param name="values">The property values to initialize on the interface</param> /// <param name="delay">The time at which the message should be delivered to the queue</param> /// <param name="pipe"></param> /// <param name="cancellationToken"></param> /// <returns>The task which is completed once the Send is acknowledged by the broker</returns> public static Task <ScheduledMessage <T> > ScheduleSend <T>(this MessageSchedulerContext scheduler, TimeSpan delay, object values, IPipe <SendContext> pipe, CancellationToken cancellationToken = default(CancellationToken)) where T : class { var scheduledTime = DateTime.UtcNow + delay; return(scheduler.ScheduleSend <T>(scheduledTime, values, pipe, cancellationToken)); }
public ScheduleMessageRedeliveryContext(ConsumeContext <TMessage> context, MessageSchedulerContext scheduler) { _scheduler = scheduler; _context = context; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IBackgroundJobClient backgroundJobs, MessageSchedulerContext context) { if (HostingEnvironment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } context.Database.Migrate(); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseHangfireDashboard("/hangfire", new DashboardOptions { Authorization = new[] { new HangfireDashboardFilter(app.ApplicationServices.GetRequiredService <IRequestAuthStrategy>()) } }); app.UseEndpoints(endpoints => { endpoints.MapControllers().RequireAuthorization(); }); app.UseMiddleware <NonApiMiddleware>(); app.UseSwagger(); app.UseSwaggerUI(c => { c.RoutePrefix = "swagger"; c.SwaggerEndpoint("/swagger/v1/swagger.json", "Message Scheduler API V1"); }); var testJob = new StartupTextJob(app.ApplicationServices.GetService <ISmsClient>(), Configuration); backgroundJobs.Enqueue(() => testJob.Execute()); RecurringJob.AddOrUpdate <SendTextJob>(job => job.Execute(), Cron.Minutely); }