question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Retries + repeated period scheduling

See original GitHub issue

Hi!

First of all, I love this library its documentation. Having in consideration the pain of working with alarms on Android, this is kind of a must.

I have two usage cases for the library, and I’ve been through all the issues (opened and closed) but I haven’t been able to see anything related to what I’m looking for:

Retries

One of my use cases, is scheduling a job that’s triggered in two minutes. If there is no connectivity, then it’s useless so I used a backoff criteria to trigger the job again in 4,8,16 minutes. My questions are:

  • Is there any way to say how many retries I want set up? Because Imagine I’m on a trip and I trigger the job. It would be there trying to triggering events forever. I don’t know if it makes a lot of sense, but I was just wondering…

Here is the code:

new JobRequest.Builder(DismissPendingFeedJob.TAG)
        .setExact(timeInMillis)
        .setPersisted(true)
        .setBackoffCriteria(TWO_MINUTES, JobRequest.BackoffPolicy.EXPONENTIAL)
        .setRequirementsEnforced(true)
        .setUpdateCurrent(true)
        .setRequiredNetworkType(JobRequest.NetworkType.CONNECTED)
        .build()
        .schedule();
  • Instead of setting a custom requirement and a back-off criteria, the first it came to my head was using a broadcast receiver to check for connectivity and then triggering a job, but Lint complains about the connectivity change intent filter:

screen shot 2017-02-08 at 17 31 03

So that means it doesn’t work anymore from Android N. I guess there is an alternative (as the lint says) using the JobScheduler or the GCMNetworkManager. Is there anything I could do with Android Job?

Repeated period scheduling

From here I’ve seen there is a way to run a job at a specific time once a day, but as I’ve seen here, we have to reeschedule the periodic jobs from the first job. That means we should always return Result.RESCHEDULE and override the reescheduling function in the job?

Thanks!!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
cesardscommented, Feb 27, 2017

I’ve been so busy, but I wanted to ask something else. If you give me one more week Ill make a couple of more questions and I’ll try to make a PR updating documentation as well 😉

0reactions
ShivamDev31commented, Sep 23, 2017

Got your point. So my use case is I start a service with Network as requirement and return RESCHEDULE from onRunJob() and in the service first step I check internet is there or not, if its not there then I stop the service. So the below method will start the service again when the network reconnects? public static void scheduleNetworkJob() { new JobRequest.Builder(TAG) .setExecutionWindow(TimeUnit.MINUTES.toMillis(1), TimeUnit.DAYS.toMillis(1)) .setRequiredNetworkType(JobRequest.NetworkType.UNMETERED) .build() .schedule(); }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retry schedules longer than a subscription's billing period
Long retry schedules that extend beyond a subscription's billing period can cause the retry schedules of multiple invoices to overlap.
Read more >
Timeouts, retries and backoff with jitter - Amazon AWS
If errors are caused by load, retries can be ineffective if all clients retry at the same time. To avoid this problem, we...
Read more >
Retry execution schedules - Boomi AtomSphere Documentation
You can add a retry schedule to a process, which automatically reruns any documents that failed during a process execution.
Read more >
Retry Section — Scheduler Administration Guide
When there have been retryable errors in the execution of the job, it only repeats those queries that have returned an error or...
Read more >
Reset exponential Schedule when combining retry and repeat ...
As long as logic fails, it's retried with exponential backoff. But as soon as it succeeds, it's repeated in fixed intervals.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found