NAME

Queue::DBI::Element - An object representing an element pulled from the queue.

VERSION

Version 2.7.0

SYNOPSIS

Please refer to the documentation for Queue::DBI.

METHODS

new()

Create a new Queue::DBI::Element object.

        my $element = Queue::DBI::Element->new(
                'queue'         => $queue,
                'data'          => $data,
                'id'            => $id,
                'requeue_count' => $requeue_count,
                'created'       => $created,
        );

All parameters are mandatory and correspond respectively to the Queue::DBI object used to pull the element's data, the data, the ID of the element in the database and the number of times the element has been requeued before.

It is not recommended for direct use. You should be using the following to get Queue::DBI::Element objects:

        my $queue = $queue->next();

lock()

Locks the element so that another process acting on the queue cannot get a hold of it

        if ( $element->lock() )
        {
                print "Element successfully locked.\n";
        }
        else
        {
                print "The element has already been removed or locked.\n";
        }

requeue()

In case the processing of an element has failed

        if ( $element->requeue() )
        {
                print "Element successfully requeued.\n";
        }
        else
        {
                print "The element has already been removed or been requeued.\n";
        }

success()

Removes the element from the queue after its processing has successfully been completed.

        if ( $element->success() )
        {
                print "Element successfully removed from queue.\n";
        }
        else
        {
                print "The element has already been removed.\n";
        }

data()

Returns the data initially queued.

        my $data = $element->data();

requeue_count()

Returns the number of times that the current element has been requeued.

        my $requeue_count = $element->requeue_count();

id()

Returns the ID of the current element

        my $id = $element->id();

get_created_time()

Returns the unixtime at which the element was originally created.

        my $created = $element->get_created_time();

is_over_lifetime()

Returns a boolean indicating whether the current element is over the lifetime specified when instanciating the queue. This is especially helpful if you retrieve a large batch of elements and do long processing operations on each of them.

        my $is_over_lifetime = $element->is_over_lifetime();

INTERNAL METHODS

get_queue()

Returns the Queue::DBI object used to pull the current element.

        my $queue = $element->get_queue();

BUGS

Please report any bugs or feature requests through the web interface at https://github.com/guillaumeaubert/Queue-DBI/issues/new. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

        perldoc Queue::DBI::Element

You can also look for information at:

AUTHOR

Guillaume Aubert, <aubertg at cpan.org>.

ACKNOWLEDGEMENTS

I originally developed this project for ThinkGeek (http://www.thinkgeek.com/). Thanks for allowing me to open-source it!

COPYRIGHT & LICENSE

Copyright 2009-2017 Guillaume Aubert.

This code is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE file for more details.