1

How to publish message to rabbitmq and read message in consumer and create a bulk products in magento while running custom queue in rabbitmq.

I want to create custom module in magento 2.3 beta to track the publisher message and processing message in consumer

1
  • Please it's urgent for me.i am trying but bulk api class not found in vendor , where it is going in vendor which files. please provide any links and etc .
    – P Ramulu
    Oct 30, 2018 at 12:19

1 Answer 1

1

I am currently implementing bulk API for products and i have created custom module for it. I had to create custom module because i receive product data from a source does not have all attributes i wanted to create a product in magento. In my module i have a function that will push product data to RabbitMQ. My function will look as below:

private function bulkPublish($products, $topic)
{
    $inputProcessed = [];
    foreach ($products as $key => $singleEntityParams) {
        $inputProcessed[$key] = $this->inputProcessor->process(
            'Magento\Catalog\Api\ProductRepositoryInterface',
            'save',
            $singleEntityParams
        );

    }
    $result = null;

    try {

        $result = $this->massSchedule->publishMass($topic, $inputProcessed)->getBulkUuid();
        //$result = $this->massSchedule->publishMass($topic, $inputProcessed)->getBulkUuid();
    } catch (Exception $e) {
        echo $e->getMessage();
        echo $e->getTraceAsString();

    }
    return $result;

}

Where: $this->inputProcessor = InpMagento\Framework\Webapi\ServiceInputProcessor; $this->massSchedule = Magento\AsynchronousOperations\Model\MassSchedule; $topic = async.magento.catalog.api.productrepositoryinterface.save.put ; $products = Formatted data based on requirement for magento API

Following command should read message from RabbitMq:

php bin/magento queue:consumers:start async.operations.all

You might run this as a cron job or anyway you want.

I know this is late to answer but adding here so that other can use if they want.

1
  • Thanks for commenting, Have already developed 1year back that above task.
    – P Ramulu
    Jan 9, 2020 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.