yigit / android-priority-jobqueue Goto Github PK
View Code? Open in Web Editor NEWA Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability.
A Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability.
From @mecid on March 1, 2015 15:58
I have Job which produce sticky event as a result of the Job. But i need to register Job to provide sticky events. Which lifecycle methods of the Job i need to use for register/unregister ? I am using Otto event bus.
Copied from original issue: path/android-priority-jobqueue#97
In JobConsumerExecutor.java
the method below causes a NPE due to val
being null
private boolean contains(String[] arr, String val) {
for (int i = 0; i < arr.length; i ++) {
if (val.equals(arr[i])) {
return true;
}
}
return false;
}
I'm implementing ActivityBoundJobs
as described in the Wiki, and cancelling Jobs when activity goes onStop().
Scenario: Activity1 launches Activity2. Activity2 calls an API to get data and JobConsumerExecutor crashes
@Override
protected void onStop() {
super.onStop();
MyApplication.getInstance()
.getJobManager()
.cancelJobsInBackground(null, TagConstraint.ANY, sessionId);
}
Refering to the implementation of NetworkUtilImpl:
https://github.com/yigit/android-priority-jobqueue/blob/master/jobqueue/src/main/java/com/path/android/jobqueue/network/NetworkUtilImpl.java
The current implementation does not take into account if app has been whitelisted by user to access network in the background. The following code should be more appropriate:
/**
* Returns true if the device is in Doze/Idle mode. Should be called before checking the network connection because
* the ConnectionManager may report the device is connected when it isn't during Idle mode.
*/
@TargetApi(23)
private static boolean isDozing(Context context) {
if (VERSION.SDK_INT >= 23) {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
final String myPackageName = context.getPackageName();
if(!powerManager.isIgnoringBatteryOptimizations(myPackageName)) {
return powerManager.isDeviceIdleMode();
} else {
return false;
}
} else {
return false;
}
}
A current workaround to this issue is to provide implementation of NetworkUtil interface while configuring JobManager.
Hey Yigit! (version 1.3.3)
I'm having a problem when I try to cancel jobs in background or in main thread also (cancelJobs). I'm trying to cancel the jobs every time I do a fetch on my collection. Like this:
Application.getInstance().getJobManager().cancelJobsInBackground(new CancelResult.AsyncCancelCallback() {
@Override
public void onCancelled(CancelResult cancelResult) {
collection.fetch();
}
}, TagConstraint.ALL, "get");
I am in a activity with several fragments that works like tabs. When I change from one fragment to another I try to update the collection in this way. That works fine when I do a change for the first time. But when I try again the cancelJobsInBackground do not give me an answer to my listener. And when I call the method cancelJobs instead, it appears to be in a eternal looping, also appearing the popup of android to close the application because it do not responds anymore. I will avoid using cancelJobsInBackground for now on. Thanks in advance.
Heitor.
Obs.:
Hi @yigit, thanks for this excellent library
I have noticed that tags from job_holder_tags table are not deleted when a job is deleted from the job_holder table, as a result tags in job_holder_tags table reference on a job that does not exists in job_holder table.
Thanks in advance
From @AndroidDeveloperLB on February 17, 2015 15:21
I got this weird exception, which I can't even find its cause because the library got obfuscated:
java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at android.database.CursorWindow.nativeGetLong(CursorWindow.java)
at android.database.CursorWindow.getLong(CursorWindow.java:511)
at android.database.AbstractWindowedCursor.getLong(AbstractWindowedCursor.java:75)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:220)
at android.database.AbstractCursor.moveToNext(AbstractCursor.java:245)
at com.path.android.jobqueue.h.a.d.b(SqliteJobQueue.java:201)
at com.path.android.jobqueue.a.a.b(CachedJobQueue.java:68)
at com.path.android.jobqueue.f.d(JobManager.java:273)
at com.path.android.jobqueue.f.c(JobManager.java:25)
at com.path.android.jobqueue.h.a(JobManager.java:412)
at com.path.android.jobqueue.d.a$b.run(JobConsumerExecutor.java:198)
at java.lang.Thread.run(Thread.java:841)
Any way to find why it occurs, and how to fix it?
Copied from original issue: path/android-priority-jobqueue#95
I'm having trouble searching your repo for any code, references, etc. because Github throws a message saying "Sorry, forked repositories are not currently searchable. You could try searching the parent repository. "
Could you figure out how to fix this please ?
Hi, the path/android-priority-jobqueue repo looks like is abandoned and this fork seems to be active. Both artifacts are available in maven central:
com.birbit:android-priority-jobqueue:1.3.1
AND
com.path:android-priority-jobqueue:1.1.2
May I assume this fork is the new active project?
Thanks, this is a great project!
Hi All,
I have developed an Broadr App(http://broadr.in) which uses this library extensively.
The app is open sourced at https://github.com/broadr
Please feel to try it(https://play.google.com/store/apps/details?id=com.abbiya.broadr) and check out the code.
Thanks,
Seshachalam.
I have an architecture problem. Some of my jobs save result to db and CursorLoader automatically update UI. What about result which not saved to db, i am using eventbus to notify UI about job work finishing, but how can i deliver result?
sample project gradle setting is out dated. Cannot run it
I have the following setup
Configuration configuration = new Configuration.Builder(this)
.minConsumerCount(0)
.maxConsumerCount(3)
.build();
Job constructor
super(new Params(0).delayInMs(2000));
Job not running after 2 seconds.
Logs:
07-05 20:35:43.501 16161-16340/com.github.ivashov.jobqueuetest D/JOBS﹕ added job id: -2147483647 class: MyJob priority: 0 delay: 1000 group : null persistent: false requires network: false
07-05 20:35:43.501 16161-16340/com.github.ivashov.jobqueuetest D/MyJob﹕ onAdded
07-05 20:35:43.511 16161-16340/com.github.ivashov.jobqueuetest D/JOBS﹕ pool-1-thread-1: load factor check. false = (0 < 0)|| (0 * 3 < 0 + 0). consumer thread: false
From @shun250 on January 7, 2015 16:59
I have a Job and when i set the delay for 10000 ms(10 seconds) the code works. The job will run with a delay. But when I increase it to 30 seconds the job almost never runs. When I am lucky the job will run. I seem to be able consistently get the delayed job to run by adding another job to the queue.
Copied from original issue: path/android-priority-jobqueue#84
I am unable to build the code using the steps outlined here: https://github.com/yigit/android-priority-jobqueue#building
i did:
$ git clone https://github.com/yigit/android-priority-jobqueue.git
$ cd android-priority-jobqueue/jobqueue
$ ./gradlew clean assembleDebug assembleDebugUnitTest test
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.IllegalArgumentException: android.compileSdkVersion is missing!
at com.android.build.gradle.internal.SdkHandler.initTarget(SdkHandler.java:80)
at com.android.build.gradle.BasePlugin.ensureTargetSetup(BasePlugin.groovy:467)
at com.android.build.gradle.BasePlugin.access$0(BasePlugin.groovy)
at com.android.build.gradle.BasePlugin$_createTasks_closure9.doCall(BasePlugin.groovy:372)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at groovy.lang.Closure.call(Closure.java:423)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy13.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:79)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:65)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:504)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:83)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)
FAILURE: Build failed with an exception.
Where:
Build file '/Users/kaja/paloma/android-priority-jobqueue/jobqueue/build.gradle' line: 6
What went wrong:
A problem occurred evaluating root project 'jobqueue'.
/Users/kaja/paloma/android-priority-jobqueue/jobqueue/releaseConfig.properties (No such file or directory)
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.551 secs
From @yigit on June 24, 2013 20:52
self explanatory :)
Copied from original issue: path/android-priority-jobqueue#2
From @mseshachalam on January 12, 2015 6:47
Does the JobScheduler work as same as JobManager ? Will there be any new changes that take advantage of JobScheduler in this library ?
Copied from original issue: path/android-priority-jobqueue#86
Hi
I'm using your great library to create jobs to sync with our API. I can easily define jobs and run job manager (jobManager.start()).
I'm syncing gallery and it's images with description. So I first add a GalleryJob with priority 1, then GalleryImageJob with priority 2. GalleryImageJob needs to access Gallery from the database, so GalleryJob has to run before GalleryImageJob.
But even if I defined priorities, it seems that sometimes GalleryImageJob (with lower priority = 2) is ran before GalleryJob (priority = 1). Is this normal?
I am getting crash reports with StackOverflowError after updating the library to version 1.3.4. There is an endless number of this call:
....
com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:304) at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:304) at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:304) at
.....
This might be a dumb question, but it wasn't immediately obvious to me after looking at the API:
I want to write a unit test to make sure the job does what I expect when it runs; is there an API so that I can test against the Job class? (without creating a job manager, etc)
onRun() im running my server call using retrofit, i got 2 callbacks success and error, how can i do (onError) to throw an exception that shouldReRunOnThrowable handles?
Thanks
Our app creates multiple job managers for different purposes. They execute their jobs sequentially.
Every now and then, our app fails because jobs arent being run - a breakpoint reveals that
running=false! and when this is detected, it seems that most (but not all) job manager instances are not running.
We didnt call stop() which appears to be the only way 'running' can be set to false.
This is killing us, and I just cant figure it out. Any help appreciated.
I have created a class that extends Job, and I added there this function (along with some other stuff):
protected JobInfo.Builder prepareLollipopJobBuilder(final Context context) {
//some code here, but even without anything it's ok for this check
return null;
}
When I create the job and schedule it, it calls "onAdded", but it never calls "onRun".
I've searched in the other posts, and the only thing I've found is this: #14
But here I don't even have a special CTOR or special fields. Only a function.
It happens even if I have the function in a class that extends from the base-job-class that extends the Job class.
Removing the function will let the job work fine.
How could it be?
To test, here's a larger piece of code:
public class PostTweetJob extends Job {
public static final int PRIORITY = 1;
public PostTweetJob(String text) {
super(new Params(PRIORITY).requireNetwork().persist());
}
protected JobInfo.Builder prepareLollipopJobBuilder(final Context context) {
return null;
}
@Override
public void onAdded() {
Log.d("AppLog", "onAdded");
}
@Override
public void onRun() throws Throwable {
Log.d("AppLog", "onRun");
}
@Override
protected RetryConstraint shouldReRunOnThrowable(Throwable throwable, int runCount,
int maxRunCount) {
return RetryConstraint.createExponentialBackoff(runCount, 1000);
}
@Override
protected void onCancel() {
}
}
And how to call it in the MainActivity :
final JobManager jobManager = new JobManager(this, new Configuration.Builder(this).build());
jobManager.addJobInBackground(new PostTweetJob("ASD"));
(long) Math.pow(initialBackOffInMs, runCount)
For example with initialBackOffInMs=1000ms it result in next delays:
1000
1000000
1000000000
i think backoff function should have at least factor parameter, for example
public static RetryConstraint createExponentialBackoff(int runCount, long initialBackOffInMs, double factor) {
RetryConstraint constraint = new RetryConstraint(true);
constraint.setNewDelayInMs((long) (initialBackOffInMs * Math.pow(factor, runCount)));
return constraint;
}
Some code: http://ideone.com/mlb1t9
May be i wrong, though
Hi,
at one a point in the past I've implemented my own job queue (which i have since discarded in favor of this project). What i do miss though is a piece functionality that would allow a new job, that is about to be added to the queue, to determine if infact it should:
This is important in situations where for example an application is running off-line for an extended period of time and jobs begin to pile up and we have user actions that cancel each other (eg: locally rename a resource 2x - it makes sense to only send the second final change to the server)
A possible way to implement this is to allow each job, at the point of being added, to examine every other job of interest on the queue and provide info on what the queue should do next (eg.: KEEP_BOTH, KEEP_SELF, KEEP_OTHER, KEEP_NONE) where KEEP_BOTH is the default (current) behaviour.
Is there anything like this on the road-map?
Cheers,
Karel
It is common that jobs need a context and many people make a mistake by passing context to a persistent job.
Instead, we can add a getApplicationContext
method to Job class and it can get it from JobManager.
Is there a way to find jobs by tag from the JobManager?
Basically I need to know if a job has already been added to the job queue for a particular tag so I don't add another one. Jobs could be queued up waiting for network state to come back on line and when it does I don't need two of the same job for the same tag being run.
If a set of tasks are marked requireNetwork and have the same groupId for sequential execution, is there a way to delay the whole queue using either exponential backoff or something else so that the sequence of delivery is not effected?
Hello.
What I want to do:
How do I do this:
As of now, the only way I see it, is to add a new job, then the old persisted jobs are running with the new one.
I expected (without reading the code) that myJobManager.start()
would start the old persisted jobs but that doesn't seem to be the case.
Is there a way to restart persisted jobs without adding a new job?
From @anti43 on December 17, 2014 14:46
.. so one can react on "last attempt" or do a Thread.sleep(numberOfFailures_1000_60) for example to get a higher chance of success later
Copied from original issue: path/android-priority-jobqueue#81
Hi ,
In my code non persistent ( new Params(1).requireNetwork() ) in working correctly and fast . But I have add the persistent in code , it not working and shows the below logcat output.
My code :
package com.az.service;
import com.az.dbhelper.DbHelper;
import com.az.model.api.Gitapi;
import com.az.model.entity.User;
import com.az.networkutil.RetrofitClient;
import com.az.ormmodel.GitUser;
import com.az.ormmodel.GitUserModel;
import com.path.android.jobqueue.Job;
import com.path.android.jobqueue.JobManager;
import com.path.android.jobqueue.Params;
import java.util.Date;
import de.greenrobot.event.EventBus;
import retrofit.Call;
import retrofit.Callback;
import retrofit.Retrofit;
/**
Created by mobilepc1 on 11/12/15.
*/
public class GetGitUsers extends Job {
//Notes : Use the persistent - store the values in disk (SQLITE) and then get and update the Value ,
// because it uses for re try and re post while app restart
DbHelper dbHelper ;
private long localId;
String userName;
GetGitUserEvent gitUserEvent;
private EventBus bus = EventBus.getDefault();
public GetGitUsers(String userName)
{
super(new Params(1).requireNetwork().persist());
this.userName =userName;
localId = -System.currentTimeMillis();
dbHelper =DbHelper.getInstance();
}
/**
Called when the job is added to disk and committed.
This means job will eventually run. This is a good time to update local database and dispatch events.
Changes to this class will not be preserved if your job is persistent !!!
Also, if your app crashes right after adding the job, {@code onRun} might be called without an {@code onAdded} call
Note that this method is called on the thread the job is added. (e.g. {@link JobManager#addJob(Job)})
is called. If job was added via {@link JobManager#addJobInBackground(Job)} or
, it will be run on JobManager's
utility thread.
*/
@OverRide
public void onAdded() {
GitUser gitUser =new GitUser(localId,userName,new Date(System.currentTimeMillis()));
dbHelper.getDaoSession().getGitUserDao().insertOrReplace(gitUser);
}
/**
The actual method that should to the work.
It should finish w/o any exception. If it throws any exception,
{@link #shouldReRunOnThrowable(Throwable, int, int)} will be called to
decide either to dismiss the job or re-run it.
*
@throws Throwable
*/
@OverRide
public void onRun() throws Throwable {
GitUserModel tweetModel = GitUserModel.getInstance();
GitUser gitUser =tweetModel.getUserLocalId(localId);
if(gitUser!=null){
dbHelper.getDaoSession().getGitUserDao().insertOrReplace(gitUser);
}
RetrofitClient retrofitClient =new RetrofitClient();
Gitapi gitService= retrofitClient.getRetrofit().create(Gitapi.class);
Call userCall =gitService.getFeed(gitUser.getUserName());
userCall.enqueue(new Callback() {
@OverRide
public void onResponse(retrofit.Response response, Retrofit retrofit) {
gitUserEvent = new GetGitUserEvent(response);
bus.post(gitUserEvent);
}
@Override
public void onFailure(Throwable t) {
gitUserEvent = new GetGitUserEvent(t.getMessage());
bus.post(gitUserEvent);
}
});
}
/**
}
}
My Logcat Error :
11-16 18:42:25.667 16416-16540/com.assistanz.aztracking E/JOBS﹕ error while serializing object GetGitUsers
java.io.NotSerializableException: de.greenrobot.event.EventBus
at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue$JavaSerializer.serialize(SqliteJobQueue.java:460)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.safeSerialize(SqliteJobQueue.java:437)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.getSerializeJob(SqliteJobQueue.java:432)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.bindValues(SqliteJobQueue.java:116)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.insert(SqliteJobQueue.java:71)
at com.path.android.jobqueue.cachedQueue.CachedJobQueue.insert(CachedJobQueue.java:30)
at com.path.android.jobqueue.JobManager.addJob(JobManager.java:166)
at com.path.android.jobqueue.JobManager$3.run(JobManager.java:397)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
11-16 18:42:25.682 16416-16540/com.assistanz.aztracking D/JOBS﹕ added job id: 14 class: GetGitUsers priority: 1 delay: 0 group : null persistent: true requires network: true
11-16 18:42:25.686 16416-16540/com.assistanz.aztracking D/JOBS﹕ pool-1-thread-1: load factor check. true = (0 < 1)|| (0 * 3 < 1 + 0). consumer thread: false
11-16 18:42:25.686 16416-16540/com.assistanz.aztracking D/JOBS﹕ adding another consumer
11-16 18:42:25.688 16416-16546/com.assistanz.aztracking D/JOBS﹕ starting consumer Thread-688
11-16 18:42:25.689 16416-16546/com.assistanz.aztracking D/JOBS﹕ looking for next job
11-16 18:42:25.689 16416-16546/com.assistanz.aztracking D/JOBS﹕ running groups
11-16 18:42:25.689 16416-16546/com.assistanz.aztracking D/JOBS﹕ non persistent result null
11-16 18:42:25.706 16416-16546/com.assistanz.aztracking D/JOBS﹕ persistent result null
11-16 18:42:25.708 16416-16546/com.assistanz.aztracking D/JOBS﹕ Thread-688: load factor check. false = (1 < 1)|| (1 * 3 < 0 + 0). consumer thread: false
11-16 18:42:25.709 16416-16546/com.assistanz.aztracking D/JOBS﹕ looking for next job
11-16 18:42:25.709 16416-16546/com.assistanz.aztracking D/JOBS﹕ running groups
11-16 18:42:25.709 16416-16546/com.assistanz.aztracking D/JOBS﹕ non persistent result null
11-16 18:42:25.709 16416-16546/com.assistanz.aztracking D/JOBS﹕ persistent result null
11-16 18:42:25.710 16416-16546/com.assistanz.aztracking D/JOBS﹕ looking for next job
11-16 18:42:25.710 16416-16546/com.assistanz.aztracking D/JOBS﹕ running groups
11-16 18:42:25.710 16416-16546/com.assistanz.aztracking D/JOBS﹕ non persistent result null
11-16 18:42:25.710 16416-16546/com.assistanz.aztracking D/JOBS﹕ persistent result null
11-16 18:42:25.711 16416-16546/com.assistanz.aztracking D/JOBS﹕ looking for next job
11-16 18:42:25.711 16416-16546/com.assistanz.aztracking D/JOBS﹕ running groups
11-16 18:42:25.711 16416-16546/com.assistanz.aztracking D/JOBS﹕ non persistent result null
11-16 18:42:25.711 16416-16546/com.assistanz.aztracking D/JOBS﹕ persistent result null
11-16 18:42:25.713 16416-16546/com.assistanz.aztracking D/JOBS﹕ looking for next job
11-16 18:42:25.713 16416-16546/com.assistanz.aztracking D/JOBS﹕ running groups
11-16 18:42:25.713 16416-16546/com.assistanz.aztracking D/JOBS﹕ non persistent result null
11-16 18:42:25.713 16416-16546/com.assistanz.aztracking D/JOBS﹕ persistent result null
11-16 18:42:25.714 16416-16546/com.assistanz.aztracking D/JOBS﹕ looking for next job
11-16 18:42:25.714 16416-16546/com.assistanz.aztracking D/JOBS﹕ running groups
11-16 18:42:25.714 16416-16546/com.assistanz.aztracking D/JOBS﹕ non persistent result null
11-16 18:42:25.714 16416-16546/com.assistanz.aztracking D/JOBS﹕ persistent result null
11-16 18:42:25.714 16416-16546/com.assistanz.aztracking D/JOBS﹕ looking for next job
11-16 18:42:25.714 16416-16546/com.assistanz.aztracking D/JOBS﹕ running groups
11-16 18:42:25.714 16416-16546/com.assistanz.aztracking D/JOBS﹕ non persistent result null
11-16 18:42:25.714 16416-16546/com.assistanz.aztracking D/JOBS﹕ persistent result null
11-16 18:42:25.715 16416-16546/com.assistanz.aztracking D/JOBS﹕ looking for next job
11-16 18:42:25.715 16416-16546/com.assistanz.aztracking D/JOBS﹕ running groups
.
.
.
Hi @yigit, thanks for project.
I have 2 jobs call and run immediately when fragment instance. But only job 1 running, job 2 not working.
How to all jobs running ??
Thanks in advance
Update: After fix and change function of my project, job 2 worked but sometimes still not working.
In custom logger :
D/JOBS: added job id: -2147483646 class: AllRecipesJob priority: 1 delay: 0 group : group1 persistent: false requires network: true
D/JOBS: SELECT * FROM job_holder WHERE _id IN ( SELECT job_id FROM job_holder_tags WHERE tag_name IN (?))
D/JOBS: running job AllRecipesJob
D/JOBS: pool-3-thread-1: load factor check. false = (1 < 1)|| (1 * 3 < 0 + 1). consumer thread: false
D/JOBS: added job id: -2147483645 class: AllVideosJob priority: 1 delay: 0 group : group2 persistent: false requires network: true
D/JOBS: pool-3-thread-1: load factor check. false = (1 < 1)|| (1 * 3 < 1 + 1). consumer thread: false
D/JOBS: finished job AllRecipesJob@422f6e90
D/JOBS: safeRunResult for AllRecipesJob@422f6e90 : true. re run:false. cancelled: false
D/JOBS: Thread-13293: load factor check. true = (0 < 1)|| (0 * 3 < 0 + 0). consumer thread: true
D/JOBS: didn't allow me to die, re-running Thread-13293
D/JOBS: re-running consumer Thread-13293
From @yigit on November 6, 2013 19:50
move building & testing to gradle.
push artifact as soon as project becomes public.
Copied from original issue: path/android-priority-jobqueue#7
SqliteJobQueue uses groups in sql w/o escaping. We should convert them to place holders or at least escape.
From @athulcek on January 30, 2015 9:49
i coded like this
if (execute())
throw new ErrorUtils("an exception");
execute will return a boolean value if the server response is false,so i need to re-try
here im getting an error
"BoxInsert" is my job class
01-30 14:51:05.630: E/(29248): error while executing job
01-30 14:51:05.630: E/BoxInsert(29248): java.lang.Exception: an exception
01-30 14:51:05.630: D/(29248): re-adding job 45
01-30 14:51:05.670: E/(29248): error while serializing object BoxInsert
Copied from original issue: path/android-priority-jobqueue#91
What does this method actually do? I'm having an issue with this, this is the stack trace:
java.lang.StackOverflowError
at java.util.LinkedHashMap.get(LinkedHashMap.java:256)
at android.util.LruCache.get(LruCache.java:97)
at android.database.sqlite.SQLiteDatabase.getCompiledStatementForSql(SQLiteDatabase.java:2192)
at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143)
at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:367)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:130)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:94)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1539)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1508)
at com.newrelic.agent.android.instrumentation.SQLiteInstrumentation.rawQuery(SQLiteInstrumentation.java:79)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:199)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:211)
at com.path.android.jobqueue.cachedQueue.CachedJobQueue.nextJobAndIncRunCount(CachedJobQueue.java:68)
at com.path.android.jobqueue.JobManager.getNextJob(JobManager.java:273)
at com.path.android.jobqueue.JobManager.access$400(JobManager.java:25)
at com.path.android.jobqueue.JobManager$2.getNextJob(JobManager.java:412)
at com.path.android.jobqueue.executor.JobConsumerExecutor$JobConsumer.run(JobConsumerExecutor.java:198)
at java.lang.Thread.run(Thread.java:1020)
As you can see it repeats a bunch of times and then triggers a stack overflow error. I want to know what does this method/what could possibly cause this so I can investigate further.
Very rarely and randomly sometimes there is such a Exception:
android.database.CursorWindow.( CursorWindow.java:108)
android.database.AbstractWindowedCursor.clearOrCreateWindow( AbstractWindowedCursor.java:198)
android.database.sqlite.SQLiteCursor.fillWindow( SQLiteCursor.java:139)
android.database.sqlite.SQLiteCursor.getCount( SQLiteCursor.java:133)
android.database.AbstractCursor.moveToPosition( AbstractCursor.java:197)
android.database.AbstractCursor.moveToNext( AbstractCursor.java:245)
com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.findJobsByTags( SqliteJobQueue.java:253)
com.path.android.jobqueue.cachedQueue.CachedJobQueue.findJobsByTags( CachedJobQueue.java:101)
com.path.android.jobqueue.JobManager$2.run( JobManager.java:309)
com.path.android.jobqueue.executor.JobConsumerExecutor.inRunningJobHoldersLock( JobConsumerExecutor.java:175)
com.path.android.jobqueue.JobManager.cancelJobs( JobManager.java:285)
com.path.android.jobqueue.JobManager$1.run( JobManager.java:238)
java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run( ThreadPoolExecutor.java:587)
java.lang.Thread.run( Thread.java:818)
In JobManager in comments you wrote:
Note that, if any of the matching jobs is running, this method WILL wait for them to finish or fail.
Inside the job we have video compressing and video uploading code, so it can take really long time to accomplish this kind of job. We want our user to be able to cancel jobs.
Can I interrupt the running job, without waiting for finish or fail?
onRun() is never called for me. I require Network and have ACCESS_NETWORK_STATE set in my Manifest.
// as you stated in another ticket, I tested this
ConnectivityManager cm = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
boolean connected = netInfo != null && netInfo.isConnectedOrConnecting();
// connected returns true
This is my Job:
public class HTTPJobExecution extends Job {
public static final int PRIORITY = 1;
private boolean error = false;
private String errorMsg = null;
private SimpleDateFormat s = new SimpleDateFormat("hh:mm:ss.SSS");
private String format = s.format(new Date());
public String URL;
public Context context;
public HTTPJobExecution(String uri, Context GivenContext){
super(new Params(PRIORITY).requireNetwork().persist());
URL = uri;
Log.v("In the Job: ", URL);
context = GivenContext;
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
error = false;
Log.v("", "I'ts: " + format + " URL: " + URL); // for testing
int timeoutSocket = 3000;
int timeoutConnection = 3000;
try{
Log.v("", "I'ts: " + format + " URL: " + URL); // for testing
HttpGet httpGet = new HttpGet(URL);
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
HttpResponse response = httpClient.execute(httpGet);
} catch (ClientProtocolException e) {
Log.v("Server not Reachable: ", URL);
errorMsg = "ClientProtocolException URL: " + URL;
error = true;
}catch (ConnectTimeoutException a){
Log.e("Server not Reachable: ", URL);
errorMsg = "ClientProtocolException URL: " + URL;
error = true;
} catch (HttpHostConnectException e) {
Log.e("Server not Reachable: ", URL);
errorMsg = "ClientProtocolException URL: " + URL;
error = true;
}
catch (IOException e) {
e.printStackTrace();
}
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
this is how I called it
jobManager.addJobInBackground(new HTTPJobExecution(s, context)); //s is a simple String
an how i initialized it:
jobManager = new JobManager(context);
even if I delete requireNetwork()
and everything in onRun()
(except a Log for check) it is not called
Hello @yigit. First of all, thank you for your great work :)
I faced with one quite serious problem after attempts to use the newly added jobs cancelation mechanism (added in v1.3).
Seems that after calling jobManager.cancelJobsInBackground
JobsQueue brakes itself and doesn't execute new jobs anymore.
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final JobManager jobManager = MyApplication.getInstance().getJobManager();
Button doJobButton = (Button) findViewById(R.id.button1);
doJobButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
jobManager.addJobInBackground(new SimpleJob());
}
});
Button cancelJobsButton = (Button) findViewById(R.id.button2);
cancelJobsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
jobManager.cancelJobsInBackground(new CancelResult.AsyncCancelCallback() {
@Override
public void onCancelled(CancelResult cancelResult) {
Collection<Job> cancelledJobs = cancelResult.getCancelledJobs();
Collection<Job> failedToCancelJobs = cancelResult.getFailedToCancel();
jobManager.clear();
jobManager.stop();
Log.d(MainActivity.class.getSimpleName(), "JobsQueue: cancelled jobs - " + cancelledJobs.size()
+ ", failed to cancel jobs - " + failedToCancelJobs.size());
}
}, TagConstraint.ALL, SimpleJob.TAG);
}
});
}
@Override
protected void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}
@Override
protected void onPause() {
super.onPause();
EventBus.getDefault().unregister(this);
}
public void onEventMainThread(JobDoneEvent event) {
Toast.makeText(this, "Job done", Toast.LENGTH_SHORT).show();
}
private static class SimpleJob extends Job {
public static String TAG = SimpleJob.class.getSimpleName();
protected SimpleJob() {
super(new Params(1).addTags(TAG));
}
@Override
public void onAdded() {
Log.d(TAG, "onAdded");
}
@Override
public void onRun() throws Throwable {
Log.d(TAG, "onRun");
Thread.sleep(TimeUnit.SECONDS.toMillis(3));
EventBus.getDefault().post(new JobDoneEvent());
}
@Override
protected void onCancel() {
Log.d(TAG, "onCancel");
}
@Override
protected int getRetryLimit() {
return 5;
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return true;
}
}
private static class JobDoneEvent {
}
}
A super-easy way to reproduce the problem using the code from above:
addJobButton
cancelJobsButton
.onAdded
method of our SimpleJob
, but onRun
won't be ever called.minConsumerCount
to something greater than 0 then JobsQueue will do attempts to keep at least one consumer thread alive draining battery life even if your application was closed.I'm using Android 5.0 on my test device. By the way, here is my config if it helps:
Configuration configuration = new Configuration.Builder(this)
.minConsumerCount(0)
.maxConsumerCount(3)
.loadFactor(3)
.consumerKeepAlive(60)
.customLogger(new JobQueueLogger())
.build();
Hey yigit
No matter what I do, I get this warning when adding a job to the manager.
E/AppLog: customLogger:error while serializing object %s java.io.NotSerializableException:
The code is simple:
JobManager jobManager=new JobManager(context,new Configuration.Builder(context).customLogger(new CustomLogger()
{
@OverRide
public boolean isDebugEnabled()
{
return true;
}
@Override
public void d(final String text,final Object... args)
{
//Log.d("AppLog","customLogger:"+text+" "+args);
}
@Override
public void e(final Throwable t,final String text,final Object... args)
{
Log.e("AppLog","customLogger:"+text+" "+t+" "+args);
}
@Override
public void e(final String text,final Object... args)
{
Log.e("AppLog","customLogger:"+text+" "+args);
}
}).build());
for(int i = 0; i < 5; i++) {
jobManager.addJobInBackground(new Job(new Params(1).requireNetwork().persist()) {
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
//Log.d("onRun - ","RUN");
}
@Override
protected void onCancel() {
}
});
}
The context is set to: private transient Context context;
What am I doing wrong here.
Best regards,
Kenneth
For some reason delayed jobs are not running in parallel for me.
Here's my config:
Configuration config = new Configuration.Builder(this)
.customLogger(new CustomLogger() {
@Override
public boolean isDebugEnabled() {
return BuildConfig.DEBUG;
}
@Override
public void d(String text, Object... args) {
Log.d("JobManager", String.format(text, args));
}
@Override
public void e(Throwable t, String text, Object... args) {
Log.e("JobManager", String.format(text, args), t);
}
@Override
public void e(String text, Object... args) {
Log.e("JobManager", String.format(text, args));
}
})
.minConsumerCount(1)
.maxConsumerCount(5)
.loadFactor(1)
.consumerKeepAlive(120) // wait 2 minutes
.build();
I'm delaying my job by 50 ms, but it won't run in parallel with my other job. I know this because I have a job that's always running which has a socket timeout of 45 seconds. The server sends a heartbeat when nothing is happening (no events). When I get an event I'd like to do something after 50 ms, but it doesn't run while this Long Poll job is running. Any idea why?
Here's a diagram:
LongPollJob(1) ---> Got Event -> add EventJobDelay(50ms) ---> add LongPollJob(2)
--> 50ms later expecting EventJob to run.
--> LongPollJob(2) ---> GotEvent ---> ... ---> add LongPollJob(3)
---> EventJob finally runs
Thanks for your help
From @daj on July 24, 2014 22:7
I create a separate instance of the JobManager for each of my automated tests. In the setUp() for each test I set the ID to be a unique String based on System.currentTimeMillis():
mJobManagerName = MyTestUtil.getUniqueID();
Configuration configuration = new Configuration.Builder(context)
.id(mJobManagerName)
<snip>
.build();
mJobManager = new JobManager(context, configuration);
Then in my tearDown() I stop and clear the job manager:
mJobManager.stop();
mJobManager.clear();
Unfortunately I can see that lots of database files are leftover after running my test suite, e.g.
-rw-rw---- u0_a49 u0_a49 20480 2014-07-24 22:04 db_1406228676565
-rw------- u0_a49 u0_a49 24072 2014-07-24 22:04 db_1406228676565-journal
This isn't causing an issue right now as the files are small, but we need a reliable way to remove them. Perhaps .clear() should tidy them up?
In the short term I will probably workaround this by deleting the files in my test tearDown(), e.g.
File dbFile = getContext().getDatabasePath("db_" + mJobManagerName);
File journalFile = getContext().getDatabasePath("db_" + mJobManagerName + "-journal");
Copied from original issue: path/android-priority-jobqueue#56
I made a small android test project to test if persistent jobs are run after app relaunch. The job simply uploads a roughly 100kb file to server and is tested on a fast wifi connection. This way if the job runs successfully I can see the file has been uploaded to server and log statements in android studio console. Here are the cases I checked.
Here is the job source code:-
package jobwars.com.jobwars.job;
import android.util.Log;
import com.path.android.jobqueue.Job;
import com.path.android.jobqueue.Params;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import de.greenrobot.event.EventBus;
/**
* Created by Fastox on 8/3/2015.
*/
public class BillImageUploadJob extends Job {
File sourceFile;
String dbId, mode;
public BillImageUploadJob(File sourceFile, String dbId, String mode) {
super(new Params(1).requireNetwork().persist());
this.sourceFile = sourceFile;
this.dbId = dbId;
this.mode = mode;
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
String fileName = sourceFile.getName();
HttpURLConnection conn = null;
DataOutputStream dos = null;
String lineEnd = "\r\n";
String twoHyphens = "--";
String boundary = "*****";
int bytesRead, bytesAvailable, bufferSize;
byte[] buffer;
int maxBufferSize = 1 * 1024 * 1024;
// open a URL connection to the Servlet
FileInputStream fileInputStream = new FileInputStream(sourceFile);
URL url = new URL("http://198.12.151.41/track/billimage?dbid=" + dbId + "&mode=" + mode);
// Open a HTTP connection to the URL
conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true); // Allow Inputs
conn.setDoOutput(true); // Allow Outputs
conn.setUseCaches(false); // Don't use a Cached Copy
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "close");
// conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("ENCTYPE", "multipart/form-data");
conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
conn.setRequestProperty("uploaded_file", fileName);
conn.setRequestProperty("UserId", dbId);
dos = new DataOutputStream(conn.getOutputStream());
dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name=\"uploaded_file\";userid=\"+dbId+\";filename=\""
+ fileName + "\"" + lineEnd);
dos.writeBytes(lineEnd);
// create a buffer of maximum size
bytesAvailable = fileInputStream.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
buffer = new byte[bufferSize];
// read file and write it into form...
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
while (bytesRead > 0) {
dos.write(buffer, 0, bufferSize);
bytesAvailable = fileInputStream.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
}
// send multipart form data necesssary after file data...
dos.writeBytes(lineEnd);
dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
// Responses from the server (code and message)
InputStream response = conn.getErrorStream();
DataInputStream inStream = null;
inStream = new DataInputStream(conn.getInputStream());
String str = "";
while ((str=inStream.readLine()) != null) {
Log.e("track billimage", "Server Response " + str);
}
inStream.close();
//close the streams //
fileInputStream.close();
dos.flush();
dos.close();
// sourceFile.delete();
EventBus.getDefault().post(new Object());
return;
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
throwable.printStackTrace();
return true;
}
@Override
protected int getRetryLimit() {
return 99000;
}
}
return true;
}
@Override
protected int getRetryLimit() {
return 99000;
}
}
The manifest:-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jobwars.com.jobwars" >
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
and the launching activity:-
package jobwars.com.jobwars;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import com.path.android.jobqueue.JobManager;
import java.io.File;
import de.greenrobot.event.EventBus;
import jobwars.com.jobwars.job.BillImageUploadJob;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
new JobManager(getApplicationContext()).addJobInBackground(new BillImageUploadJob(new File("/storage/emulated/0/pic.jpg"), "10", "0"));
return true;
}
return super.onOptionsItemSelected(item);
}
public void onEventMainThread(Object o) {
Toast.makeText(this, "image uploaded", Toast.LENGTH_SHORT).show();
}
@Override
protected void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}
@Override
protected void onStop() {
super.onStop();
EventBus.getDefault().unregister(this);
}
}
Would really appreciate if anyone can point to why the jobs are not persistent.
From @yigit on June 21, 2013 22:52
right now, for the jobs w/ same priority; job manager checks retry count before deciding which one should run first.
this is an issue for things like messaging where request order is important.
We can remove checking retry count but in that case, this will be a problem because some failing request will block all jobs.
We should provide a way to define groups of jobs so that they will run in the order they were give (+priority) and this order will be preserved for retries.
Copied from original issue: path/android-priority-jobqueue#1
Hi, I get this error when trying to add a new Job:
Is this a Bug or am I doing something wrong?
-09 19:21:50.710 28332-30164/com.mypackage E/SQLiteLog﹕ (1032) statement aborts at 20: [INSERT INTO job_holder VALUES (?,?,?,?,?,?,?,?,?)]
10-09 19:21:50.710 28332-30164/com.mypackage E/SQLiteDBG﹕ func: executeNonQuery, errno: 2, error msg: No such file or directory, path: /data/data/com.mypackage/databases/db_default_job_manager, handle: 0xb8173718
10-09 19:21:50.710 28332-30164/com.mypackage E/JOBS﹕ addJobInBackground received an exception. job class: SendMsgJob
android.database.sqlite.SQLiteReadOnlyDatabaseException: attempt to write a readonly database (code 1032)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:812)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.insertWithTags(SqliteJobQueue.java:85)
at com.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.insert(SqliteJobQueue.java:63)
at com.path.android.jobqueue.cachedQueue.CachedJobQueue.insert(CachedJobQueue.java:28)
at com.path.android.jobqueue.JobManager.addJob(JobManager.java:165)
at com.path.android.jobqueue.JobManager$3.run(JobManager.java:396)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Hi There.
I have implemented the Path library alongside retrofit for my rest uploads.
There are approximately 100 uploads a second and sometimes 5-10 of them produce a 504 gateway error. For some reason Path isn't seeing this and not rerunning it again.
The error is happening here in onRun():
try {
Response response = null;
if (service != null) {
response = service.uploadReading(reading);
}
if (response != null) {
assert response.getStatus() == 200;
uploadCount++;
}
} catch (RetrofitError re) {
Log.e(TAG, "There was an error uploading: "+re.toString());
}
My configuration is as follows:
Configuration configuration = new Configuration.Builder(this)
.customLogger(new CustomLogger() {
private static final String TAG = "JOBS";
@Override
public boolean isDebugEnabled() {
return true;
}
@Override
public void d(String text, Object... args) {
Log.d(TAG, String.format(text, args));
}
@Override
public void e(Throwable t, String text, Object... args) {
Log.e(TAG, String.format(text, args), t);
}
@Override
public void e(String text, Object... args) {
Log.e(TAG, String.format(text, args));
}
})
.minConsumerCount(1)//always keep at least one consumer alive
.maxConsumerCount(100)//up to 3 consumers at a time
.loadFactor(10)//3 jobs per consumer
.consumerKeepAlive(120)//wait 2 minute
.build();
jobManager = new JobManager(this, configuration);
What am I missing or not understanding?
Thanks in advance
hi,
any chance you could update the examples with Dagger2 ? there's been a lot of a questions on stackoverflow,etc. about this.. but nobody knows the correct way.
From @ckozak on February 7, 2015 0:36
I have a following scenario in which I consistently get duplication of jobs.
Configuration configuration = new Configuration.Builder(getContext())
.minConsumerCount(1) //always keep at least one consumer alive
.maxConsumerCount(1) //up to 3 consumers at a time
.loadFactor(1) //3 jobs per consumer
.consumerKeepAlive(120) //wait 2 minute
.build();
I'm trying to get sequential jobs execution. Parallelization is not that important to me.
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return throwable instanceof AuthException;
}
Copied from original issue: path/android-priority-jobqueue#92
From @m4hmoud on January 19, 2015 12:5
Is there any way to cancel the current job in onAdded()
and before even onRun()
gets called?
Copied from original issue: path/android-priority-jobqueue#89
From @m4hmoud on January 19, 2015 10:45
I was just trying this in my app and I read the documentation for the onAdded()
method:
This is a good place to dispatch a UI event...
My first thought was this is like pre-process in AsyncTask and it runs in the same thread (in this case UI thread) that it was called. But it seems that when using addJobInBackground(job)
, this method is also called in the background thread. Thus, not really a good place for UI change logic...
Am I missing something or shouldn't this logic be mentioned in the docs?
Copied from original issue: path/android-priority-jobqueue#88
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.