OiO.lk Blog PHP laravel issue with sending data to rabbitmq
PHP

laravel issue with sending data to rabbitmq


i have this issue in my code: i have 2 microservices laravel 10: in the 1st one i send to the queue a variable like this:

        Queue::connection('rabbitmq')->push('App\Jobs\UpdateProductStock', $orderData);

and in the job that will recieve this it shows :
local.ERROR: Unresolvable dependency resolving [Parameter #0 [ $orderData ]] in class App\Jobs\UpdateProductStock {"exception":"[object]
in the reciever job i have :

namespace App\Jobs;

use App\Models\Product;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Queue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Queue;
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Connectors\RabbitMQConnector;

class UpdateProductStock implements ShouldQueue
{


    /**
     * Create a new job instance.
     */
    public $orderData;

    public function __construct($orderData)
    {
        $this->orderData = $orderData;
    }

    /**
     * Execute the job.
     */
    public function handle()
    {
        Log::info("Test job executed successfully.");

so i understand that the variable sent by the 1st service was not recieved to the 2nd one.
any help please ?

i have tried to change the job structure like this:

use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Connectors\RabbitMQConnector as BaseJob;

class UpdateProductStock extends BaseJob
{


    /**
     * Create a new job instance.
     * @return void
     */


    /**
     * Execute the job.
     */
    public function fire()
    {$payload = $this->getRawBody();

but it gives indefined method getRawBody



You need to sign in to view this answers

Exit mobile version