NAME
Messaging::Message::Queue::DQN - abstraction of a Directory::Queue::Normal message queue
SYNOPSIS
use Messaging::Message;
use Messaging::Message::Queue::DQN;
# create a message queue
$mq = Messaging::Message::Queue::DQN->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::Normal module that provides a generic directory based queue.
It uses the following Directory::Queue::Normal schema to store a message:
$schema = {
header => "table",
binary => "binary?",
text => "string?",
};
The message header is therefore stored as a table and the message body is stored either as a text or binary string.
METHODS
In addition to the methods inherited from Directory::Queue::Normal, the following methods are available:
- new(OPTIONS)
-
return a new Messaging::Message::Queue::DQN object (class method), the OPTIONS are the ones for Directory::Queue::Normal->new()
- 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::Normal, Messaging::Message, Messaging::Message::Queue.
AUTHOR
Lionel Cons http://cern.ch/lionel.cons
Copyright (C) CERN 2011-2013