Bernard Labno [https://community.jboss.org/people/blabno] created the discussion

"Job manager/dispatcher pattern"

To view the discussion, visit: https://community.jboss.org/message/822316#822316

--------------------------------------------------------------
Hello

In my app there are some long running tasks that can be started from web 
front-end. Admin should see progress of those tasks in the same front-end.
What is the best approach to implement this?

Right now I have 1 ApplicationScoped JobManager and ~20 task executors running 
on separate JVM's (simple standalone apps). Those executors periodically (fast) 
pool JobManager for jobs through JAX-RS.
JobManager must know which job is executed by which executor so that it's not 
done twice. Also that information must be persistent (in case of JobManager 
crash/restart).
{code:lang=java}
public String assignJob(String executorId) {
    Job job = get1stUnassignedJobFromDB();
    job.setExecutorId(executorId);
    saveJobInDB(job);
    return job.getId();
}{code}

The problem is that sometimes executor 1 gets job A, the transaction doesn't 
get commited yet and the executor 2 also get's the same job.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/822316#822316]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to