jeudi 25 juillet 2019

How to send json message to sqs by using laravel?

I am beginner in Laravel. Please suggest me the solution step by step. In my task, I need to do following points:-

  1. In a controller, store contents of csv file in an array. --- Completed
  2. In same controller, send step 1. array in json format to sqs (amazon) by using laravel. --- Pending

  3. 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

  1. Created a job php artisan make:job SendMessageSQS

  2. Call SendMessageSQS::dispatch();

  3. 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;}"}}

  1. 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;

  1. Actual Result: SQS should store below format
{"file-name":"test-sqs-1","user-id":"1,2,3"}



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ycdoZt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire