1 year ago

Making Job w Redis throttle and chunk?

Posted 1 year 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', '') ->where($opc) ->select('') ->orderBy('', '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/

So i tried that

DB::table('locations') ->join('leads', 'locations.lead_id', '') ->where($opc) ->select('') ->orderBy('', '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.