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


Manual Reference Pages  -  TATSUMAKI::MESSAGEQUEUE (3)

.ds Aq ’

NAME

Tatsumaki::MessageQueue - Message Queue system for Tatsumaki

CONTENTS

SYNOPSIS

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);
        }
    });



DESCRIPTION

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.

CONFIGURATION

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

METHODS

    publish

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

poll($client_id, CW$code_ref)

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.

poll_once($client_id, CW$code_ref)

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

AUTHOR

Tatsuhiko Miyagawa

SEE ALSO

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


perl v5.20.3 TATSUMAKI::MESSAGEQUEUE (3) 2010-12-21

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