How about having task 1 queue task 2 and task 2 queuing task 3? On Apr 26, 5:53 pm, king <[email protected]> wrote: > Hi all, I encounter a queueing related challenge and need you guys' > help badly: > > The use case is that I have 3 tasks that I want to insert into the > queue. Each task takes about 20 seconds to complete. The challenge is > that task # 3 depends on task # 2, and task # 2 depends on task # 1. > The question is, how can I insert those 3 tasks and expect task 1 be > finished before task 2 starts, and task 2 be finished before task 3 > starts? > > Base upon my current knowledge about GAE, I am thinking about wrapping > a new transaction around every single task such as follows: > > ------------------------------------------------- > // run task #1 > Queue queue = QueueFactory.getDefaultQueue(); > Transaction tx = pm.currentTransaction(); > try { > tx.begin(); > > queue.add(DatastoreServiceFactory.getDatastoreService().getCurrentTransaction(), > TaskOptions().url("/task1.jsp")); > tx.commit(); > > } finally { if (tx.isActive()) { tx.rollback();} } > > // run task #2 > tx = pm.currentTransaction(); > try { > tx.begin(); > > queue.add(DatastoreServiceFactory.getDatastoreService().getCurrentTransaction(), > TaskOptions().url("/task2.jsp")); > tx.commit(); > > } finally { if (tx.isActive()) { tx.rollback();} } > > // run task #3 > tx = pm.currentTransaction(); > try { > tx.begin(); > > queue.add(DatastoreServiceFactory.getDatastoreService().getCurrentTransaction(), > TaskOptions().url("/task2.jsp")); > tx.commit();} finally { if (tx.isActive()) { tx.rollback();} } > > ------------------------------------------------- > > where task2.jsp and task3.jsp both perform select, update and insert > operations based upon the datastore contents from the prior tasks (ie, > task 3 depends on task 2, and task 2 depends on task 1). > > Is this the right way to implement the synchronous queued tasks? Is > there a better solution out there offered by GAE? Your help is > greatly appreciated and thanks in advance. > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine for Java" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/google-appengine-java?hl=en.
-- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
