Messagi...ue::DQN(3)

πŸ“¦ version 1.6.1, in epel 9

NAME πŸ’–

okay so bestie, this is Messaging::Message::Queue::DQN β€” filed under Messagi...ue::DQN(3) in the User Contributed Perl Documentation, and it’s literally the abstraction of a Directory::Queue::Normal message queue. yes, that’s the whole NAME vibe πŸ’…βœ¨


SYNOPSIS πŸ¦‹

here’s the entire group-chat demo, no cap:

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 πŸŽ€

so like, this module provides an abstraction of a message queue. It derives from the Directory::Queue::Normal module, which provides a generic directory based queue. iconic inheritance moment fr fr.

It uses the following Directory::Queue::Normal schema to store a message:

$schema = {
    header => "table",
    binary => "binary?",
    text   => "string?",
};

so the message header is therefore stored as a table, and the message body is stored either as a text or binary string β€” slay πŸ’…


METHODS 🌟

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

new(OPTIONS) ✨

return a new Messaging::Message::Queue::DQN object (class method), and the OPTIONS are the ones for Directory::Queue::Normal->new(). periodt.

add_message(MESSAGE) 🫢

add the given message (a Messaging::Message object) to the queue and return the corresponding element name. cute, useful, ate.

get_message(ELEMENT) πŸ’«

get the message from the given element (which must be locked β€” do not skip the lock, bestie 😭) and return a Messaging::Message object.


SEE ALSO πŸ‘€

go peek at these too:

  • Directory::Queue::Normal
  • Messaging::Message
  • Messaging::Message::Queue

AUTHOR πŸ’œ

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

Copyright (C) CERN 2011-2016


xoxo, this little page is brought to you by perl v5.32.1, dated 2019-07-26 πŸ«ΆπŸ’–

πŸ“¦ where this page comes from