Laravel Job integrate PHP native via rabbitmq

32 Views Asked by At

The Target Is Send Message from PHP Native to laravel Job Consummer

i try to copy payload from laravel

{"uuid":"520f1d38-c647-4929-8d7c-71c525312476","displayName":"App\\Jobs\\CalSaldoAfterTrasaction","job":"Illuminate\\Queue\\CallQueuedHandler@call","maxTries":3,"maxExceptions":null,"failOnTimeout":false,"backoff":null,"timeout":null,"retryUntil":null,"data":{"commandName":"App\\Jobs\\CalSaldoAfterTrasaction","command":"O:32:\"App\\Jobs\\CalSaldoAfterTrasaction\":2:{s:43:\"\u0000App\\Jobs\\CalSaldoAfterTrasaction\u0000client_id\";s:36:\"83e77dea-4b7b-4cee-a63f-b295923aab1b\";s:39:\"\u0000App\\Jobs\\CalSaldoAfterTrasaction\u0000batch\";s:5:\"09-00\";}"},"id":"eaabf064-9450-456a-b2ff-9642503f6ceb"}

on payload will run class App\Jobs\CalSaldoAfterTrasaction with paramater is client_id = 83e77dea-4b7b-4cee-a63f-b295923aab1b and batch=09-00

i will send queue from php native and laravel will execute this job request

this my code.

$connection = new AMQPStreamConnection($RBc['host'],$RBc['port'],$RBc['username'],$RBc['password'],$RBc['vhost']);
    $channel = $connection->channel();
    $channel->queue_declare($RBc['queue'], false, true, false, false);
    $channel->queue_bind($RBc['queue'], $RBc['exchange']);
     $m=[
                'uuid'=>$uuid,
                'displayName'=>'App\Jobs\CalSaldoAfterTrasaction',
                "job"=>"Illuminate\\Queue\\CallQueuedHandler@call",
                "maxTries"=>3,
                "maxExceptions"=>null,
                "failOnTimeout"=>false,
                "backoff"=>null,
                "timeout"=>null,
                "retryUntil"=>null,
                "data"=>[
                    "commandName"=>"App\\Jobs\\CalSaldoAfterTrasaction",
                    "command"=>"O:32:\"App\\Jobs\\CalSaldoAfterTrasaction\":2:{s:43:\"\u0000App\\Jobs\\CalSaldoAfterTrasaction\u0000client_id\";s:36:\"83e77dea-4b7b-4cee-a63f-b295923aab1b\";s:39:\"\u0000App\\Jobs\\CalSaldoAfterTrasaction\u0000batch\";s:5:\"08-00\";}"
                ],
                "id"=>$uuid

                
            ];
            $message = new AMQPMessage(json_encode($m), ['content_type' => 'application/json', 'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT]);
              
            $channel->basic_publish($message, $RBc['exchange']);
            $channel->close();
            $connection->close();

this not work now.

so how to build this function same like this

$x=new App\Jobs\CalSaldoAfterTrasaction('83e77dea-4b7b-4cee-a63f-b295923aab1b',$batch);
$r=Queue::laterOn('default',4000, $x);
0

There are 0 best solutions below