On Tue, Mar 2, 2010 at 9:29 PM, Jian <[email protected]> wrote:
> Here are the steps I'm currently doing:
>
> 1. I run this page first for putting jobs in the queue (10 Jobs):
> ...
> 2. Then I run a page that reserves two(2) jobs: This works as
> expected.
> ...
> unset($pheanstalk);

By unseting the $pheanstalk variable, you permit PHP to close the
connection. A reservation in beanstalkd evaporates when the reserving
connection is closed. So this line causes the two reserved jobs to go
back in the ready queue. From this point on, all 10 jobs are once more
available to be reserved.

> 3. Here's the problem, when I run the third page that reserves another
> job, it still gets the first job (Job 1) in the queue although it WAS
> ALREADY RESERVED PREVIOUSLY (step 2). This happens also when using
> "peek".

Now job 1 is first in line, since all 10 jobs are ready and job 1 was
the first to be submitted. So you get job 1.

> The workaround that I'm doing is I "bury" the job as soon as it has
> been reserved.

Nothing wrong with that, but it'll be a tiny bit more efficient if you
can hang on to the beanstalkd connection.

(It's been suggested that we should have a way to hold a reservation
independent from the connection, thus making connections a little less
stateful. I'm not opposed to that, and I have some ideas about how it
might work, but I think we should think carefully about any new
feature. I welcome discussion on this subject.)

>  Is this the expected behavior of the reserve and peek command? Or I
> might be missing something here.

It is expected. I hope this helps you get going. Let us know either way!

kr

-- 
You received this message because you are subscribed to the Google Groups 
"beanstalk-talk" 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/beanstalk-talk?hl=en.

Reply via email to