GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Tatsumaki::MessageQueue(3) User Contributed Perl Documentation Tatsumaki::MessageQueue(3)

Tatsumaki::MessageQueue - Message Queue system for Tatsumaki

To publish a message, you first create an instance of the message queue on a specific channel:

    my $mq = Tatsumaki::MessageQueue->instance($channel);
    $mq->publish({
        type => "message", data => $your_data,
        address => $self->request->address,
        time => scalar Time::HiRes::gettimeofday,
    });

Later, in a handler, you can poll for new messages:

    my $mq = Tatsumaki::MessageQueue->instance($channel);
    my $client_id = $self->request->param('client_id')
        or Tatsumaki::Error::HTTP->throw(500, "'client_id' needed");
    $mq->poll_once($client_id, sub { $self->write(\@_); $self->finish; });

Additionally, if you are using Multipart XmlHttpRequest (MXHR) you can use the event API, and run a callback each time a new message is published:

    my $mq = Tatsumaki::MessageQueue->instance($channel);
    $mq->poll($client_id, sub {
        my @events = @_;
        for my $event (@events) {
            $self->stream_write($event);
        }
    });

Tatsumaki::MessageQueue is a simple message queue, storing all messages in memory, and keeping track of a configurable backlog. All polling requests are made with a $client_id, and the message queue keeps track of a buffer per client, to ensure proper message delivery.

BacklogLength
To configure the number of messages in the backlog, set $Tatsumaki::MessageQueue::BacklogLength. By default, this is set to 30.

This method publishes a message into the message queue, for immediate consumption by all polling clients.

This is the event-driven poll mechanism, which accepts a callback as the second parameter. It will stream messages to the code ref passed in.

This method returns all messages since the last poll to the code reference passed as the second parameter.

Tatsuhiko Miyagawa

Tatsumaki
2010-12-21 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.