Home  |  Linux  | Mysql  | PHP  | XML
From:(Justin Mason) Date:Mon Mar  5 04:24:07 2007
Subject:Re: usage question
hi Thomas --

an interesting use-case I hadn't considered! ;)  The problem is that
when the queue is accessed in ordered mode, it's simply a lexical
sort by filename; and when accessed in unordered mode, it's simply
the OS-based ordering rather than in any way "random".

What about re-queueing the deferred jobs?  ie.

  	my $dq = IPC::DirQueue->new( \%dq_opts );
  	while (1) {
  		my $job = $dq->pickup_queued_job();
  		last if (! $job);
  
  		my $rc = &process_job( $job );
  		if (!$rc) {
  			$job->enqueue_file($job->get_data_path());
  		}
                $job->finish();
  	}

in other words, if a job is to be deferred, take it off the queue
and re-queue it under a new name.

Alternatively, I'd be happy to apply a patch that implements
a version of visit_all_jobs() which allows writes somehow, or
a way to access a job returned by visit_all_jobs() and render
it writable.

--j.

Thomas J Pinkl writes:
> I'm attempting to use IPC::DirQueue 0.08 for a project where messages 
> are queued for later processing.  However, when dequeuing these 
> messages, it will be possible that a message cannot be processed 
> immediately, but could be processed later. 
> 
> I thought I'd be able to use IPC::DirQueue like this: 
> 
> 	my $dq = IPC::DirQueue->new( \%dq_opts );
> 	while (1) {
> 		my $job = $dq->pickup_queued_job();
> 		last if (! $job);
> 
> 		my $rc = &process_job( $job );
> 		if ($rc) {
> 			$job->finish();
> 		} else {
> 			$job->return_to_queue();
> 		}
> 	}
> 
> But if, say, the first job is returned to the queue, then a subsequent 
> call to pickup_queued_job() returns that same job.  Turning the loop 
> above into an infinite loop (absent an external event which suddenly 
> causes process_job() to return true). 
> 
> I've read through the IPC::DirQueue and IPC::DirQueue::Job pod pages, 
> but I'm not seeing any way to iterate through the queue the way that I 
> need.  The closest method I can see is visit_all_jobs(), but that only 
> provides read-only Job objects.  I suppose I could play with the 
> read-only flag within the callback function, but that doesn't seem 
> right.
> 
> Does anyone have any suggestions?
> 
> -- 
> Thomas J. Pinkl                     |  T: 215-442-9300
> Senior Systems Architect            |     800-444-1427
> Health Business Systems, Inc        |  F: 215-442-7555
> An SXC Company                      |  
> 738 Louis Drive                     |  http://www.hbsrx.com/
> Warminster, PA 18974                |  http://www.sxc.com/
Navigate in group perl.ipc.dirqueue at sever nntp.perl.org
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants