NAME

Messaging::Message::Queue::DQS - abstraction of a Directory::Queue::Simple message queue

SYNOPSIS

use Messaging::Message;
use Messaging::Message::Queue::DQS;

# create a message queue
$mq = Messaging::Message::Queue::DQS->new(path => "/some/where");

# add a message to the queue
$msg = Messaging::Message->new(body => "hello world");
printf("msg added as %s\n", $mq->add_message($msg));

# browse the queue
for ($name = $mq->first(); $name; $name = $mq->next()) {
    next unless $mq->lock($name);
    $msg = $mq->get_message($name);
    # one could use $mq->unlock($name) to only browse the queue...
    $mq->remove($name);
}

DESCRIPTION

This module provides an abstraction of a message queue. It derives from the Directory::Queue::Simple module that provides a generic directory based queue.

It simply stores the serialized message (with optional compression) as a Directory::Queue::Simple element.

METHODS

In addition to the methods inherited from Directory::Queue::Simple, the following methods are available:

new(OPTIONS)

return a new Messaging::Message::Queue::DQS object (class method), the OPTIONS are the ones for Directory::Queue::Simple->new() with the addition of compression, like for Messaging::Message->jsonify()

add_message(MESSAGE)

add the given message (a Messaging::Message object) to the queue and return the corresponding element name

get_message(ELEMENT)

get the message from the given element (which must be locked) and return a Messaging::Message object

SEE ALSO

Directory::Queue::Simple, Messaging::Message, Messaging::Message::Queue.

AUTHOR

Lionel Cons http://cern.ch/lionel.cons

Copyright (C) CERN 2011-2021