Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JobScheduler - How do I determine a unique Job ID?

According to the documentation, jobs must have a unique Job ID per uid.
If I use a 3rd party library which also schedules jobs, does this mean I can't use the same Job ID as theirs? If so, how can I avoid these kind of collisions?

like image 228
Ori Wasserman Avatar asked Jun 07 '17 13:06

Ori Wasserman


2 Answers

If I use a 3rd party library which also schedules jobs, does this mean I can't use the same Job ID as theirs?

Correct.

If so, how can I avoid these kind of collisions?

Ask the developer of the library what job IDs they use, or if those job IDs are configurable somehow.

like image 119
CommonsWare Avatar answered Nov 09 '22 11:11

CommonsWare


If asking the developer of library doesn't work, you may want to calculate md5 on package name and pick last 4 bytes as unique id. The chances of collision will be quite less.

like image 35
bbindra Avatar answered Nov 09 '22 11:11

bbindra