Skip to content

Upgrading from 0.45

1.0 is a breaking release, and doesn’t share queues with 0.4x apps: upgrade every app that shares jobs together, onto empty queues. The full list of changes is in the changelog.

  • RabbitMQ 4.4 or later. 1.0 refuses older servers: it needs the quorum queues’ delayed delivery.
  • Empty queues. 1.0 declares quorum queues, and has no scheduled, error or stats queues. RabbitMQ won’t redeclare a classic queue as a quorum queue: let the 0.4x apps drain their queues and delete them, or give 1.0 a new NamePrefix or virtual host. Messages of 0.4x aren’t migrated, scheduled and periodic ones included.

Use MassiveJobs.Core and MassiveJobs.RabbitMqBroker. Remove:

  • MassiveJobs.Core.Hosting and MassiveJobs.RabbitMqBroker.Hosting: Core does the hosting now.
  • MassiveJobs.Logging.Log4Net, .NLog, .Serilog: MassiveJobs logs through Microsoft.Extensions.Logging; plug your logger in there.
  • MassiveJobs.SqlServerBroker: removed.

JobsBuilder.Configure()…Build() and services.AddMassiveJobs().UseRabbitMqBroker() become one way for every app:

// 0.45
JobsBuilder.Configure()
.WithRabbitMqBroker(s =>
{
s.HostNames = new[] { "rabbit.example.com" };
s.Username = "massive";
s.Password = "secret";
})
.Build();
// 1.0
services.AddMassiveJobs()
.WithJobsFromAssemblyOf<SendWelcomeEmailJob>()
.UseRabbitMq(o => o.ConnectionString = "amqp://massive:secret@rabbit.example.com/");
0.45 1.0
MassiveJobsSettings MassiveJobsOptions, standard .NET options
RabbitMqSettings RabbitMqOptions, with ConnectionString
Build(startWorkers: false) o.StartWorkers = false
JobsBuilder.DisposeJobs() the host stops it; without one, StopAsync and MassiveJobsMediator.Deinitialize()
RabbitMqSettings.PrefetchCount MassiveJobsOptions.BatchSize
ScheduledWorkersCount, PeriodicWorkersCount gone: no scheduled queues, one periodic queue
*WorkersBatchSize BatchSize

Without a host, start MassiveJobs once the service provider is built: await MassiveJobsMediator.Initialize(provider).StartAsync().

The defaults changed too: 4 immediate queues (was 2) and 2 long-running (was 1), each running one job at a time (was 2). An app still runs 4 immediate jobs at once.

  • Register them. Only registered jobs are published and run: WithJobsFromAssemblyOf<T>() for the Job/JobAsync classes of a project, WithJob<T>() for others. Messages carry the job’s tag instead of .NET type names: the class’s full name by default, or [JobTag("...")]. See Jobs.
  • Private nested job classes must become internal: the source generator can’t call them.
  • The job’s constructor is chosen by ActivatorUtilities, every parameter from the job’s scope.
  • Timeouts are enforced for jobs published with one: a job that runs past it is abandoned and retried.
  • MaxRetries counts retries: with 25 a job runs at most 26 times (it was 25).

PublishPeriodic and CancelPeriodic are gone. Periodic jobs are defined in code, with an attribute on the job class:

// 0.45, at startup
CleanupJob.PublishPeriodic("cleanup", "0 0 3 * * ?");
// 1.0
[PeriodicJob("cleanup", "0 0 3 * * ?")]
public class CleanupJob : Job<CleanupJob> { ... }

To stop one, remove the attribute. See Periodic jobs.

The static Publish methods still work, and gained async twins: await MyJob.PublishAsync(args). IJobPublisher gained PublishAsync, and every Publish extension method has an async twin: prefer them. JobBatch.Do gained DoAsync, and batches can be nested.