Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I've never used it, but I'm game. Here's my first try. You'll note that instead of AnyEvent::RabbitMQ, I used AnyEvent::RabbitMQ::Fork:
#!/usr/bin/perl BEGIN { $ENV{'PERL_ANYEVENT_STRICT'} = 1; } use strict; use warnings; use FindBin; use Data::Dumper::Concise; my %server = ( product => undef, version => undef, ); my %conf = ( host => 'localhost', port => 5672, user => 'guest', pass => 'guest', vhost => q{/}, verbose => 1, ); eval { use IO::Socket::INET; my $socket = IO::Socket::INET->new( Proto => 'tcp', PeerAddr => $conf{'host'}, PeerPort => $conf{'port'}, Timeout => 1, ) or die 'Error connecting to AMQP Server!'; close $socket; }; use AnyEvent::RabbitMQ::Fork; my $ar = AnyEvent::RabbitMQ::Fork->new(verbose => $conf{'verbose'}); $ar->load_xml_spec(); my $done = AnyEvent->condvar; $ar->connect( (map {$_ => $conf{$_}} qw(host port user pass vhost)), tune => { frame_max => 2**17 }, timeout => 1, on_success => sub { my $ar = shift; $server{product} = $ar->server_properties->{product}; $server{version} = version->parse($ar->server_properties->{ver +sion}); $done->send; }, on_failure => failure_cb($done), on_return => sub { my $method_frame = shift->method_frame; die "return: ", $method_frame->reply_code, $method_frame->repl +y_text if $method_frame->reply_code; }, on_close => sub { my $method_frame = shift->method_frame; Carp::confess "close: ", $method_frame->reply_code, $method_fr +ame->reply_text if $method_frame->reply_code; }, ); sub failure_cb { my ($cv) = @_; return sub { $cv->send; }; } AnyEvent->condvar->recv;
You can find more examples at: rabbit-tutorials. The examples use Net::RabbitMQ, which has been more thoroughly tested than the AnyEvent modules. I hope that this helps you.

In reply to Re: AnyEvent::RabbitMQ not connecting? by Khen1950fx
in thread AnyEvent::RabbitMQ not connecting? by Riales

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (3)
    As of 2019-07-18 02:36 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?