AMQP

 view release on metacpan or  search on metacpan

LICENSE  view on Meta::CPAN


                     END OF TERMS AND CONDITIONS

        Appendix: How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.

  To do so, attach the following notices to the program.  It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) 19yy  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 1, or (at your option)
    any later version.

lib/AMQP/Publisher.pm  view on Meta::CPAN

has 'heartbeat' => 30;
has 'exchange' => 'log';
has 'type' => 'topic';
has 'key' => '#';
has 'rabbit';
has 'connection';
has 'channel';
has 'status';
has 'on_connect';

sub attach {
	my $self = shift;
	$self->status(AnyEvent->condvar);
	$self->rabbit(AnyEvent::RabbitMQ->new);
	$self->rabbit->load_xml_spec();
	$self->rabbit->connect(
		host => $self->host,
		port => $self->port,
		user => $self->user,
		pass => $self->password,
		vhost => $self->vhost,

lib/AMQP/Publisher.pm  view on Meta::CPAN

 use AMQP::Publisher;
 my $publisher = AMQP::Publisher->new;
 $publisher->server('amqp://foo:bar@localhost:5672/testing');
 $publisher->exchange('test');
 $publisher->type('topic');
 $publisher->queue('testing');
 $publisher->on_connect( sub {
 	my ($self) = @_;
	$self->channel->send('hello world');
 });
 $publisher->attach;

=head1 DESCRIPTION

The AMQP::Publisher publishes messages to an AMQP exchange

=head1 METHODS

B<new()> (constructor)

Creates a new AMQP::Producer which can 

lib/AMQP/Publisher.pm  view on Meta::CPAN

B<server($url)>

Configures all of the connection settings based on an AMQP url.  The format of which is:
  
 amqp://username:password@host:port/vhost

All of the elements of the url are required if you are not using the defaults.  The default settings are:

 amqp://guest:guest@localhost:5672/

B<attach()>

Connects to the AMQP server specified by the C<server()> method.  When the server connects it will invoke the publisher's C<on_connect()>
callback.  This can enable you to setup additional event loops to drive the publisher.


B<send()>

After the Publisher object has attached to the AMQP server, it is capable of sending messages to the configured exchange and key.


B<exchange( $exchange )>

An accessor to the configured exchange.  

B<key( $key )>
 
And accessor to the configured routing key.

lib/AMQP/Subscriber.pm  view on Meta::CPAN

has 'type' => 'topic';
has 'key' => '#';
has 'queue' => 'test';
has 'rabbit';
has 'connection';
has 'channel';
has 'status';
has 'tag' => $ENV{LOGNAME} . "@" . hostname;
has 'on_message';

sub attach {
	my $self = shift;
	$self->useragent(Mojo::UserAgent->new);
	$self->status(AnyEvent->condvar);
	$self->rabbit(AnyEvent::RabbitMQ->new);
	$self->rabbit->load_xml_spec();
	$self->rabbit->connect(
		host => $self->host,
		port => $self->port,
		username => $self->username,
		pass => $self->password,

lib/AMQP/Subscriber.pm  view on Meta::CPAN

 use AMQP::Subscriber;
 my $subscriber = AMQP::Subscriber->new;
 $subscriber->server('amqp://foo:bar@localhost:5672/testing');
 $subscriber->exchange('test');
 $subscriber->type('topic');
 $subscriber->queue('testing');
 $subscriber->callback( sub {
 	my ($self,$message) = @_;
	say $message;
 });
 $subscriber->attach;

=head1 DESCRIPTION

The AMQP::Subscriber wraps 

=head1 METHODS


B<new( \%params )> (constructor)

lib/AMQP/Subscriber.pm  view on Meta::CPAN

B<server($url)>

Configures all of the connection settings based on an AMQP url.  The format of which is:
  
 amqp://username:password@host:port/vhost

All of the elements of the url are required if you are not using the defaults.  The default settings are:

 amqp://guest:guest@localhost:5672/

B<attach()>
 

=head1 TODO


=head1 BUGS

If you find them out

=head1 COPYRIGHT



( run in 0.672 second using v1.01-cache-2.11-cpan-88abd93f124 )