Batching jobs & scheduling

We’re new to Hangfire Pro but are enjoying it so far.

Perhaps we aren’t using it correctly, but here’s our current issue:

We’re sending SMS messages out one at a time and are doing so using Batches.

Our probably wrong understanding of how batching worked was that if we BackgroundJob.Schedule 100 SMS messages inside a BatchJob, that all of these 100 messages would be able to be identified as being part of that ‘batch’. If this was the case we would then be able to treat them all as members of that batch, and be able to cancel / reschedule / etc. based on the batch ID.

However, while the backgroundjob.schedule works nicely inside the batchjob, once all 100 SMS message jobs have been scheduled, we don’t see any way of identifying them as belonging to a batch.

Are we missing a step? have we misunderstood the functionality?

Our code is basically this:

        //Hangfire Pro Batch Send
        GlobalConfiguration.Configuration.UseBatches();

        BatchJob.StartNew(async x =>
        {
            foreach (var message in messagegroup)
            {
                var primaryJobId = BackgroundJob.Schedule(sms sending code);
                var secondaryJobId = BackgroundJob.ContinueWith(primaryJobId, () => RemoveSuccessJob(primaryJobId));

Update: we found our error…

we forgot to use the variable ‘x’… so now our code looks like this, and we now have beautiful little batches full of SMS jobs!

var primaryJobId = x.Schedule(sms sending code);