It took me awhile to first understand how to use the Queue API new in Drupal 7 so how about an example? There's some documentation at http://api.drupal.org/api/group/queue/7 but it's not great.

Since there's not really any UI behind using the Queue API I'm thinking of making a simple form and a few pages.

First page is a form with a textfield that when submitted the field is queued. Another page would get the queued items. A subsequent request to the second page would inform the user that a lease exists on any queued items. A third page would be a confirm form or deleting queued items.

Comments

rfay’s picture

Title: Queue API example » Develop a Queue API example

A fantastic idea.

coltrane’s picture

Status: Active » Needs review
StatusFileSize
new5.89 KB

Here's an example module. It provides a page for creating queue items and another for viewing them and deleting. Marking this CNR for time being but I still need to write tests. Any feedback is welcome.

Thanks!

rfay’s picture

Status: Needs review » Needs work

Thanks so much for this! It's going to help lots of people.

+++ queue_example/queue_example.module	8 Apr 2010 05:58:51 -0000
@@ -0,0 +1,171 @@
+ * @file
+ * Examples demonstrating the Drupal Queue API.

Please add a paragraph here that gives an explanation of the Queue API and the key buzzwords used with it. I see "claim" and "leased". Also please add a link to any and all handbook or api.d.o documentation there is.

+++ queue_example/queue_example.module	8 Apr 2010 05:58:51 -0000
@@ -0,0 +1,171 @@
+    'title' => 'Queue item example',

I think just "Queue Example"

Please implement hook_help() with a decent description of what's going on with each page. I'm unfamiliar with the term "claim" in queueing context, and was not clear what it meant to release. The entire "items" page was a mystery. Does it work correctly? I think if you implement hook_help() for those two pages things will be much better.

And as you said, tests would be much appreciated.

Powered by Dreditor.

chx’s picture

i will review this later

rfay’s picture

I'd like to see still more functionality (BatchQueue and MemoryQueue, for example) demonstrated here. John VanDyk's DrupalconSF presentation is a nice resource: video and slides

rfay’s picture

Status: Needs work » Needs review
StatusFileSize
new16.97 KB

OK, here's another pass at this, with more user interface and added comments, and tests.

rfay’s picture

Status: Needs review » Fixed

I committed this to HEAD: http://drupal.org/cvs?commit=370440.

Thanks, @coltrane for showing me how it works and getting this started.

Followup issues are encouraged.

rfay’s picture

Followup to fix a typo in the test: http://drupal.org/cvs?commit=372390

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

webchick’s picture

Version: » 7.x-1.x-dev

Just a note to say THANKS! This is a wonderful example module. Appreciated the pointer to http://www.ent.iastate.edu/it/Batch_and_Queue.pdf too.