caxtor has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks!, I am having trouble with the Thread::Pool and the Amazon::SQS::Simple modules, it seems they have the some subs that are the same... Here is my code:

use Amazon::SQS::Simple; use Thread::Pool; my $sqs = new Amazon::SQS::Simple($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCE +SS_KEY); my $q = $sqs->GetQueue($QUEUE_URL); my $msg; while (1) { $msg = $q->ReceiveMessage(); if ($msg != "") { #New message found, process message print $msg->MessageBody(); } else { print "No new messages.\n" } #Polling interval sleep(2); }

My problem seems to be with the RecieveMesseges function...

I get this error:

Prototype mismatch: ($;$$) vs none at (eval 1808) line 2, <VERSION> li +ne 797. Prototype mismatch: ($;$) vs none at (eval 1810) line 2, <VERSION> lin +e 824. Prototype mismatch: ($$) vs none at (eval 1812) line 2, <VERSION> line + 842. Prototype mismatch: ($) vs none at (eval 1814) line 2, <VERSION> line +880. Prototype mismatch: sub Net::SSLeay::randomize (;$$$) vs none at (eval + 1815) line 2, <VERSION> line 902. Prototype mismatch: ($$$) vs none at (eval 1824) line 2, <VERSION> lin +e 1202. Prototype mismatch: ($$$) vs none at (eval 1825) line 2, <VERSION> lin +e 1206. Prototype mismatch: ($$;**) vs none at (eval 1826) line 2, <VERSION> l +ine 1219. Could not find file for 'XML::LibXML::SAX' at /usr/local/share/perl/5. +12.4/load.pm line 214.

Replies are listed 'Best First'.
Re: Prototype mismatch
by JavaFan (Canon) on Apr 12, 2012 at 18:18 UTC
    Amazon::SQS::Simple doesn't export any subs by default, so it seems very unlikely that this is clashing.

    But are you sure you're giving us the code that generates these messages? The last one talks about line 214, and while I didn't count the lines of your snippet, I'm pretty sure it isn't 214 lines long.

    Note, this is not an invitation to post 214 or more lines of code. But it does help to post code and errors that match.

      Full code here:

      use strict; use Carp qw( carp croak ); #********************************************************************* +** # Configuration: #********************************************************************* +*/ my $QUEUE_URL = "https://queue.amazonaws.com/..."; my $AWS_ACCESS_KEY_ID = ""; my $AWS_SECRET_ACCESS_KEY = ""; #********************************************************************* +** # USE Amazon Libraries #********************************************************************* +*/ use Amazon::SQS::Simple; #********************************************************************* +** # USE Other Libraries #********************************************************************* +*/ use Thread::Pool; #********************************************************************* +*** # Create new objects #********************************************************************* +**/ #AMAZON SQS my $sqs = new Amazon::SQS::Simple($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCE +SS_KEY); $| = 1; #Quick buffer #-----------------------------------------------------------------# my $q = $sqs->GetQueue($QUEUE_URL); my $msg; while (1) { $msg = $q->ReceiveMessage(); if ($msg != "") { #New message found, process message print $msg->MessageBody(); #$pool->job($body); print " -> Job sent to pool!\n"; #Delete message from queue #$q->DeleteMessage($msg->ReceiptHandle()); } else { print "No new messages.\n" } #Polling interval sleep(2); }
        So, what's on line 214 of load.pm, and how does that get called?
Re: Prototype mismatch
by Khen1950fx (Canon) on Apr 12, 2012 at 22:49 UTC
    I encountered two problems: missing dependencies and proper use of load.pm. I fixed the dependencies with this:
    #!/usr/bin/perl use strict; use warnings; use CPAN; CPAN::Shell->install(qw( load Thread::Serialize Thread::Tie Thread::Conveyor Thread::Conveyor::Monitored Thread::Queue XML::NamespaceSupport XML::SAX::Base XML::SAX XML::SAX::Expat XML::LibXML::SAX XML::Simple WWW::RobotRules HTML::Tagset HTML::Parser HTTP::Date Encode::Locale LWP::UserAgent LWP::MediaTypes HTTP::Headers HTTP::Headers::Util HTTP::Status HTTP::Daemon Net::HTTP URI HTTP::Negotiate File::Listing));
    This fixed the ptoyotype mismatch in load.pm:
    #!/usr/bin/perl BEGIN { eval { do { use strict; use warnings; } }; } use load qw(AutoLoader now); use Thread::Pool; use Amazon::SQS::Simple; my $queue_url = 'https://queue.amazon.com'; my $access_key = q{id}; my $secret_key = q{key}; my $sqs = new Amazon::SQS::Simple($access_key, $secret_key); my $q = $sqs->GetQueue($queue_url); my $msg; while (1) { $msg = $q->ReceiveMessage(); if ($msg != "") { print $msg->MessageBody(); } else { print "No new messages.\n" } sleep(2); }
    The rest is up to you.

      What is this supposed to do?

      BEGIN { eval { do { use strict; use warnings; } }; }

      You can delete the whole thing and the rest of the code will behave the same way.


      Improve your skills with Modern Perl: the free book.

        It's there to do nothing---that's why I put it there. A simple use strict; seemed counter-productive, based on my understanding of load.

      Thanks Khen1950fx, The AutoLaoder seemed to fix the Prototype Mismatch, but I am still unable to go past the load.pm error:

      Could not find file for 'XML::LibXML::SAX' at /usr/local/share/perl/5.12.4/load.pm line 214.

      I also had to add $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; as it was failing...

      I'm guessing RecieveMessage is NOT thread safe??