To use this example, first run sql/create_tables.sql SQL to add it to a database, using the 'psql' options to vary the connection details as needed:

psql -f ../sql/create_tables.sql

Then you can run this script. If you haven't installed Job::Machine into a global path, make sure the libraries can be found. If you want to a connect to a different database name than the default, you can use the PGDATABASE enviroment variable:

PGDATABASE=other perl -I../lib ./test.pl

What this script will do is to start a single Worker which connects to the queue to watch. For the purpose of demonstation the worker will create a Client during the startup phase, which will add a single job to the queue.

The Worker will so find the job process it, and reply to the Client. The client will then acknowledge receipt of the message from the worker, and then the whole script will end.

Throughout the run TAP diagnostic output will be printed to STDOUT, confirming for you what's happening. The output will look like this:

ok 1 - Send a task
ok 2 - - Did we get what we sent?
ok 3 - Check for no message
ok 4 - Talking to ourself
ok 5 - - But do we listen?
ok 6 - - Did we hear what we said?
ok 7 - Uncheck first message
1..7