SQS implementation as an adapter for spryker/queue
1.0.0
2023-08-01 15:11 UTC
Requires
- php: >=7.4
- spryker/kernel: ^3.56.0
- spryker/log: ^3.7.0
- spryker/queue: ^1.5.0
- spryker/symfony: ^3.5.0
- spryker/transfer: ^3.25.0
- valantic-spryker/aws-sqs: ^0.8.0
Requires (Dev)
- codeception/module-asserts: ^1.3.0
- codeception/stub: ^3.6.1
- phpstan/phpstan: ^1.0.0
- spryker/code-sniffer: ^0.17.1
- spryker/testify: ^3.40.0
This package is auto-updated.
Last update: 2024-11-09 13:19:15 UTC
README
SQS implementation as an adapter for spryker/queue
Install package
composer req valantic-spryker-eco/sqs
Update shared config
config/Shared/config_default.php
$config[KernelConstants::CORE_NAMESPACES] = [
...
'ValanticSpryker',
];
Update your shared config for SQS (sample for ElasticMQ)
$config[SqsConstants::SQS_BASE_URL] = 'http://elasticmq:9324';
$config[SqsConstants::SQS_QUEUE_PATH_PREFIX] = 'queue/';
Update your QueueConfig
\Pyz\Zed\Queue\QueueConfig
...
/**
* @var string
*/
public const AWS_SQS = 'aws-sqs';
...
/**
* @return array
*/
protected function getMessageCheckOptions(): array
{
return [
QueueConstants::QUEUE_WORKER_MESSAGE_CHECK_OPTION => [
...
static::AWS_SQS => $this->getAwsSqsQueueMessageCheckOptions(),
];
}
...
/**
* @return \Generated\Shared\Transfer\AwsSqsConsumerOptionTransfer
*/
protected function getAwsSqsQueueMessageCheckOptions(): AwsSqsConsumerOptionTransfer
{
$queueOptionTransfer = new AwsSqsConsumerOptionTransfer();
$queueOptionTransfer->setCheckMessageCount(true);
return $queueOptionTransfer;
}
...
Update your ConsoleDependencyProvider
\Pyz\Zed\Console\ConsoleDependencyProvider
/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Symfony\Component\Console\Command\Command[]
*/
protected function getConsoleCommands(Container $container): array
{
$commands = [
...
new SqsCreateQueuesConsole(),
new SqsPurgeAllQueuesConsole(),
new SqsRemoveQueuesConsole(),
];
In many cases when you operate SQS next to RabbitMq, it will make sense to also extend the Queue module to separate RabbitMq workers from SQS workers. To achieve this you should extend QueueDependencyProvider and QueueBusinessFactory to create Task and Worker for RabbitMq and SQS independently.