queue_url => null
jackdpeterson opened this issue · 16 comments
After issue #37 is integrated that resolves the missing version number, another error arises.
To summarize, it seems like the $name being passed in to SlmQueueSqs\Queue\SqsQueue __construct method is
"SlmQueueSqs\Queue\SqsQueue" rather than the expected queue name. Furthermore, this leaves the queue_url as being null (queueUrl in $this->queueOptions).
I haven't yet narrowed down where the issue is at ... but something seems amiss when one defined the following:
'slm_queue' => array(
'queue_manager' => array(
'factories' => array(
'queue-test-processor' => 'SlmQueueSqs\Factory\SqsQueueFactory'
)
),
'queues' => array(
'queue-test-processor' => array(
'queue_url' => sprintf('https://sqs.amazonaws.com/#####OBSCURED#####/queue-test-module-%s', APPLICATION_ENV)
)
),
inside my factory, I have the following (works with the AWS v2 and Slm 0.4 side of things):
<?php
namespace QueueTest\ControllerFactory;
use Zend\ServiceManager\FactoryInterface;
use QueueTest\Controller\QueueTestController;
class QueueTestControllerFactory implements FactoryInterface
{
public function __invoke($serviceManager)
{
try {
$parentLocator = $serviceManager->getServiceLocator();
$queueManager = $parentLocator->get('SlmQueue\Queue\QueuePluginManager');
$queue = $queueManager->get('queue-test-processor');
$statusTracker = $parentLocator->get('immutable-state-status-tracker');
$controller = new QueueTestController($statusTracker, $queue);
return $controller;
} catch (\Exception $e) {
echo $e->getMessage();
}
}
/**
*
* {@inheritdoc}
*
* @see \Zend\ServiceManager\FactoryInterface::createService()
*/
public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
{
return $this->__invoke($serviceLocator);
}
}
I'm thinking there's an issue with either SlmQueue's plugin manager ... or the SlmQueueSQS plugin manager that for some reason isn't getting the right name passed in.
ping @basz, you did tell you tested the new version didn't you? Can you please have a look? :)
what does composer show | grep 'zend-'
say?
zend/zend-studio-development-mode 1.0.1 Zend Framework 2 module that helps the Zend Framework 2 application to be developed with Zend Studio
zendframework/zend-authentication 2.5.3 provides an API for authentication and includes concrete authentication adapters for common use case scenarios
zendframework/zend-barcode 2.6.0 provides a generic way to generate barcodes
zendframework/zend-cache 2.7.1 provides a generic way to cache any data
zendframework/zend-captcha 2.6.0
zendframework/zend-code 2.6.3 provides facilities to generate arbitrary code using an object oriented interface
zendframework/zend-config 2.6.0 provides a nested object property based user interface for accessing this configuration data within application code
zendframework/zend-console 2.6.0
zendframework/zend-crypt 2.6.0
zendframework/zend-db 2.8.1
zendframework/zend-debug 2.5.1
zendframework/zend-developer-tools dev-master 4d8a2e4 Module for developer and debug tools for use with zend-mvc applications.
zendframework/zend-di 2.6.1
zendframework/zend-diactoros 1.3.5 PSR HTTP Message implementations
zendframework/zend-dom 2.6.0 provides tools for working with DOM documents and structures
zendframework/zend-escaper 2.5.1
zendframework/zend-eventmanager 2.6.3
zendframework/zend-feed 2.7.0 provides functionality for consuming RSS and Atom feeds
zendframework/zend-file 2.7.0
zendframework/zend-filter 2.7.1 provides a set of commonly needed data filters
zendframework/zend-form 2.9.0
zendframework/zend-http 2.5.4 provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) requests
zendframework/zend-hydrator 1.1.0
zendframework/zend-i18n 2.7.3
zendframework/zend-i18n-resources 2.5.2 Provides validator translations for zend-i18n's Translator
zendframework/zend-inputfilter 2.7.2
zendframework/zend-json 2.6.1 provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP
zendframework/zend-loader 2.5.1
zendframework/zend-log 2.9.0 component for general purpose logging
zendframework/zend-mail 2.7.1 provides generalized functionality to compose and send both text and MIME-compliant multipart e-mail messages
zendframework/zend-math 2.7.0
zendframework/zend-memory 2.5.2
zendframework/zend-mime 2.6.0
zendframework/zend-modulemanager 2.7.2
zendframework/zend-mvc 2.7.10
zendframework/zend-navigation 2.8.1 provides support for managing trees of pointers to web pages
zendframework/zend-paginator 2.7.0
zendframework/zend-permissions-acl 2.6.0 provides a lightweight and flexible access control list (ACL) implementation for privileges management
zendframework/zend-permissions-rbac 2.5.1 provides a role-based access control management
zendframework/zend-progressbar 2.5.2 component to create and update progressbars in different environments
zendframework/zend-psr7bridge 0.2.2 PSR-7 <-> Zend\Http bridge
zendframework/zend-serializer 2.8.0 provides an adapter based interface to simply generate storable representation of PHP types by different facilities, and recover
zendframework/zend-server 2.7.0
zendframework/zend-servicemanager 2.7.6
zendframework/zend-session 2.7.2 manage and preserve session data, a logical complement of cookie data, across multiple page requests by the same client
zendframework/zend-soap 2.6.0
zendframework/zend-stdlib 2.7.7
zendframework/zend-tag 2.6.1 a component suite which provides a facility to work with taggable Items
zendframework/zend-test 2.6.1
zendframework/zend-text 2.6.0
zendframework/zend-uri 2.5.2 a component that aids in manipulating and validating » Uniform Resource Identifiers (URIs)
zendframework/zend-validator 2.8.1 provides a set of commonly needed validators
zendframework/zend-version 2.5.1
zendframework/zend-view 2.8.0 provides a system of helpers, output filters, and variable escaping
zendframework/zend-xmlrpc 2.6.0
Okay, so I've been playing with this a bit more -- just to ensure I don't have Aws misconfigured.
When I manually run:
$SQSClient = $this->aws->createSqs();
var_dump($SQSClient->listQueues());
echo "Queue URL for queue-test-module-development: ";
var_dump($SQSClient->getQueueUrl([
'QueueName' => 'queue-test-module-development'
]));
I get expected output (after defining the appropriate version, either in configuration with ['aws' => ['Sqs' => ['version' => 'latest']]) or with the #37 approach (closing and not merging since the configuration way works just as well).
So ... that seems to just leave the plugin manager not passing the right 'name' in.
Also, If I get rid of the manually defined queue_url section and name the 'queue' to be consistent with the actual queue name on AWS the issue persists ... so neither manual configuration, nor automagic discovery resolves to the right Queue.
Output from echoing the exception:
An exception was raised while creating "queue-test-module-development"; no instance returnedError executing "GetQueueUrl" on "https://sqs.us-east-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://sqs.us-east-1.amazonaws.com` resulted in a `400 Bad Request` response:
<?xml version="1.0"?><ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><Error><Type>Sender</Type><Code>A (truncated...)
AWS.SimpleQueueService.NonExistentQueue (client): The specified queue does not exist for this wsdl version. - <?xml version="1.0"?><ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><Error><Type>Sender</Type><Code>AWS.SimpleQueueService.NonExistentQueue</Code><Message>The specified queue does not exist for this wsdl version.</Message><Detail/></Error><RequestId>4e1b6879-bf02-5646-9ded-279459dadc7a</RequestId></ErrorResponse>======================================================================
The application has thrown an exception!
======================================================================
Zend\ServiceManager\Exception\ServiceNotCreatedException
The factory was called but did not return an instance.
----------------------------------------------------------------------
If I add in:
/**
* SqsQueueFactory
*/
class SqsQueueFactory implements FactoryInterface
{
/**
*
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @return SqsQueue
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
echo "__invoke for SqsQueueFactory\n";
echo "Container: " . get_class($container) . "\n";
echo "requestedName: " . $requestedName . "\n";
echo "options: " . var_export($options, true) . "\n";
I get:
Container: Zend\ServiceManager\ServiceManager
requestedName: SlmQueueSqs\Queue\SqsQueue
options: NULL
Yeah, I think I see what’s going on…
But, I can’t seem to configure SQS permissions correctly for a test project…. Keep getting AWS.SimpleQueueService.NonExistentQueue (client): The specified queue does not exist for this wsdl version.
Annoying… I’ll keep trying a bit more
IAM Policy sample: works if you DIRECTLY use the SqsClient from AWS.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1467211138000",
"Effect": "Allow",
"Action": [
"sqs:*"
],
"Resource": [
"arn:aws:sqs:us-east-1:###YOUR_ACCOUNT_ID_HERE###:*"
]
}
]
}
Otherwise you get the non-existent queue problem if you're working inside of the SlmQueueSQS module.
could you change https://github.com/juriansluiman/SlmQueueSqs/blob/master/src/SlmQueueSqs/Factory/SqsQueueFactory.php#L46
into
return $this($parentLocator, $requestedName);
Yep, that fixes it up quite nicely!
i'll submit a PR
My Bad. Great! Should only affect servicemanager 2.*
ping bakura10 to tag a hotfix (no commit rights pour moi :-) ) when your done...
Okay, please ping me on the PR :).
I'm going to squash first, so hold up a sec :-)
In my tests i notice that for SQS the MaxPollingFrequencyStrategy is nessescary.
However, I would assume it should only wait when there are no jobs on the queue. It does not do that.
It processes a job and then waits a bit, next job, wait, next....
If I change it to listen to the Idle Event then waits with polling only when there are no jobs...
Can you (@bakura10) confirm that that would be the desired behaviour?
btw. used for test purposes https://github.com/basz/sim-queue-test-application
Sorry for the commit spam here -- the latest squashed one has the formatting changes I made in documentation looking better.
Just tagged as 0.6.1! :)