win-local-inc/message-bus
Message Bus Package
- All honor go to joblocal/laravel-sqs-sns-subscription-queue
Installation
-
PHP 8.1 is required
-
remove
sqs-snsfromconfig/queue.php, it will be added by provider, or update it with
'sqs-sns' => [
'driver' => 'sqs-sns',
'key' => env('AWS_SQS_ACCESS_KEY_ID'),
'secret' => env('AWS_SQS_SECRET_ACCESS_KEY'),
'queue' => env('AWS_SQS_QUEUE', 'your-queue-url'),
'region' => env('AWS_SQS_REGION', 'us-east-2'),
'topic' => env('AWS_SNS_TOPIC'),
'routes' => [
env('AWS_SNS_TOPIC') => 'WinLocal\\MessageBus\\Jobs\\SqsGetJob',
],
'version' => 'latest',
'ua_append' => [
'L5MOD/'.\Aws\Laravel\AwsServiceProvider::VERSION,
],
],
- add envs :
AWS_SQS_HANDLER_PATHS= app paths to handlers separeted by "," resolved by App::path($path)
AWS_SQS_VALIDATOR_PATHS= app paths to validators separeted by "," resolved by App::path($path)
AWS_SQS_ACCESS_KEY_ID=
AWS_SQS_SECRET_ACCESS_KEY=
AWS_SQS_REGION=us-east-2
AWS_SQS_QUEUE=
AWS_SNS_TOPIC=
- handlers:
There are two ways to implement handlers
- Standard
Laravel Jobsee -> WinLocal\MessageBus\Tests\Data\Handlers\AdvertCreated.php - Interface
WinLocal\MessageBus\Contracts\ExecutorInterfacesee -> WinLocal\MessageBus\Tests\Data\Handlers\AudienceCreated.php
Attribute WinLocal\MessageBus\Attributes\HandleSubjects needs to be used, so resolver will use it.
- validators:
There is optional validator available, that will be excecuted before handlers. Validator needs to extend WinLocal\MessageBus\Contracts\AbstractExecutorValidator see -> WinLocal\MessageBus\Tests\Data\Validators\AudienceCreated.php
- push notification:
WinLocal\MessageBus\Jobs\SnsSendJob::dispatch(\WinLocal\MessageBus\Enums\Subject $subject, array $message);
- each service needs to run supervisor
php artisan queue:work sqs-sns --max-jobs=100 --tries=3 --max-time=3600
- to run tests on package
vendor/bin/testbench package:test --configuration=tests/phpunit.xml
Related Packages
A Symfony Messenger inspired message bus for Laravel: buses, middleware, transpo...
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 3.0.6 | ^8.1| | ^v8.0.0| | MIT | |
| 3.0.5 | ^8.1| | ^v8.0.0| | MIT | |
| 3.0.4 | ^8.1 | ^v8.0.0| | MIT | |
| 3.0.3 | ^8.1 | ^v8.0.0| | MIT | |
| 3.0.2 | ^8.1 | ^v8.0.0| | MIT | |
| 3.0.1 | ^8.1 | ^v8.0.0| | MIT | |
| 3.0 | ^8.1 | ^v8.0.0| | MIT | |
| 2.0.25 | ^8.1 | ^v8.0.0| | MIT | |
| 2.0.24 | ^8.1 | ^v8.0.0| | MIT | |
| 2.0.23 | ^8.1 | ^v8.0.0| | MIT | |
| 2.0.22 | ^8.1 | ^v8.0.0| | MIT | |
| 1.0.9 | ^7.1| | ^v7.0.0| | MIT |