1

I have an app wherein from laravel 4.2 I am slowly transitioning it to node.

Now I have this Queue::pushRaw(payload, tube) the job is in node and this code is working perfectly fine.

However I recently have a problem wherein I need those jobs to have a delay.

I use Queue::later before (when my jobs is still in Laravel), but how can I do it with Queue::pushRaw ?? I can't use Queue::later anymore since I'm passing a raw payload instead of a job.

Base on the documents I can pass options https://laravel.com/api/4.2/Illuminate/Queue/QueueInterface.html

However, I have no idea what to pass on options to have a delay.

I am L
  • 4,288
  • 6
  • 32
  • 49

2 Answers2

0

Upon further investigation, I discovered this file: https://github.com/laravel/framework/blob/4.2/src/Illuminate/Queue/BeanstalkdQueue.php#L66 (I'm using Beanstald)

You can't really pass a delay since DEFAULT_DELAY is 0.

So my solution is to create a job in Laravel.

I can then do Queue::later(delay, myJobThatCallsThePushRaw, data, queue);

and then on myJobThatCallsThePushRaw I do Queue::pushRaw(my-node-payload) inside.

Hope this helps someone in the future.

I am L
  • 4,288
  • 6
  • 32
  • 49
0

I did this delay in my code, I added a field in database, before I do my job, I check last time of check.If past X second, OK you can do this job, other side requeue with delay.

in the consumer of my queue:

 RabbitmqFacade::consumer('trx_need_to_confirm_check', function ($data) {
                $message = json_decode($data->body, true);


                if ($message['type'] == 1) {
                    $operationResult = $this->tronMainConfirmService->startService($message);
                }
                else {
                    $operationResult = $this->tronMainWithdrawalService->startCheckConfirmService($message);
                }

                if (!$operationResult['ackAble']) {
                    RabbitmqFacade::product('trx_need_to_confirm_check', $message, true, true, 30000);
                }
                $data->ack();
            });
Hamid Naghipour
  • 3,465
  • 2
  • 26
  • 55