I am beginner in Laravel. Please suggest me the solution step by step. In my task, I need to do following points:-
- In a controller, store contents of csv file in an array. --- Completed
-
In same controller, send step 1. array in json format to sqs (amazon) by using laravel. --- Pending
-
For step 2), I have set the config/queue.php
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.ap-northeast-1.amazonaws.com/xxxxxxx'),
'queue' => env('SQS_QUEUE', 'xxxxx'),
'region' => env('AWS_DEFAULT_REGION', 'ap-northeast-1'),
],
Also changed .env file
AWS_ACCESS_KEY_ID=AKIAWZZU3ONK52Z2VZWF
AWS_SECRET_ACCESS_KEY=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
SQS_QUEUE=smartsearch-datasale-realtime
-
Created a job php artisan make:job SendMessageSQS
-
Call
SendMessageSQS::dispatch();
-
SQS received message
{"displayName":"App\\Jobs\\SendMessageSQS","job":"Illuminate\\Queue\\CallQueuedHandler@call","maxTries":null,"delay":null,"timeout":null,"timeoutAt":null,
"data":{"commandName":"App\\Jobs\\SendMessageSQS","command":"O:21:\"App\\Jobs\\SendMessageSQS\":3:{s:7:\"\u0000*\u0000item\";s:7:\"testing\";s:10:\"connection\";
s:7:\"sqs\";s:6:\"\u0000*\u0000job\";N;}"}}
- How to send
$userIDs = [1,2,3]; // array values from csv file column `user-is`
$sendMessageSqs["file-name"] = "test-sqs-1";
$sendMessageSqs["user-id"] = $userIDs;
- Actual Result: SQS should store below format
{"file-name":"test-sqs-1","user-id":"1,2,3"}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire