jok3r

Making Job w Redis throttle and chunk?

Posted 2 months ago by jok3r

Hi everybody, i'm so n00b... Have a problem trying make a job.

I want notified a lot of users any thing but massive . So i make a job sendCrentials (for example) and has 2 steps first, call all user from db and i use chunk something like this:

DB::table('locations') ->join('leads', 'locations.lead_id', 'leads.id') ->where($opc) ->select('leads.id') ->orderBy('locations.id', 'DESC') ->chunk(1, function($leads){ foreach ($leads as $lead) { //step 2 } }); so in step2 call an api one by one lead id, so $result = json_decode(apiRequest(['json' => $object])); and the when result its Ok send and sms and its all but my job die and log says:

Illuminate\Queue\MaxAttemptsExceededException: App\Jobs\sendCredentials has been attempted too many times or run too long. The job may have previously timed out. in /home/ubuntu/gmb.virket.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:400

So i tried that

DB::table('locations') ->join('leads', 'locations.lead_id', 'leads.id') ->where($opc) ->select('leads.id') ->orderBy('locations.id', 'DESC') ->chunk(1, function($leads){ foreach ($leads as $lead) { Redis::throttle('send_credentials_massive')->allow(1)->every(2)->then(function () { $result = json_decode(apiRequest(['json' => $object])); //send email }, function () { return $this->release(); }); } });

but return 500 ... help me please

Please sign in or create an account to participate in this conversation.