Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Jonk::C...Handling(3) User Contributed Perl DocumentationJonk::C...Handling(3)

NAME
       Jonk::Cookbook::ErrorHandling - error handling enqueue and dequeue

USAGE
       enqueue script:

	   #! perl
	   use strict;
	   use warnings;
	   use DBI;
	   use Jonk::Client;

	   my $dbh = DBI->connect('dbi:mysql:test','user','pass');
	   my $jonk = Jonk::Client->new($dbh);
	   my $job_id =	$jonk->enqueue('worker_key','job_data_here');
	   if ($jonk->errstr) {
	       die $jonk->errstr;
	   }

       worker script:

	   #! perl
	   use strict;
	   use warnings;
	   use DBI;
	   use Jonk::Worker;
	   use Your::Worker;

	   my $dbh = DBI->connect('dbi:mysql:test','user','pass');
	   my $jonk = Jonk::Worker->new($dbh =>	{functions => [qw/worker_key/]});

	   while (1) {
	       my $job = $jonk->dequeue;
	       if ($jonk->errstr) {
		   die $jonk->errstr;
	       }
	       if ($job) {
		   Your::Worker->work($job);
	       } else {
		   sleep(3); # wait for	3 sec.
	       }
	   }

perl v5.32.1			  2010-11-25		 Jonk::C...Handling(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=Jonk::Cookbook::ErrorHandling&sektion=3&manpath=FreeBSD+13.1-RELEASE+and+Ports>

home | help