Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Asynchronous Bulk API

Eugene Tulika edited this page Mar 30, 2018 · 1 revision

Async Bulk

Async Bulk API allows to accept multiple entities as a part of one request. While processing of the entities, they will be separated into multiple messages stored in the message queue. We cannot re-use routes declared in webapi.xml for such messages, because some request parameters such as entity id is not available while storing multiple entities at once. New configuration file will be introduced as a part of this module.

Configuration

Configuration of the Async Web API will define the relation between endpoint url="/async/V1/products" method="POST" and Message Queue topic topic="products.created" The endpoint will accept messages in the format defined by following rules:

  1. take the schema of the message configured for the topic
  2. accept array of messages identified by this schema

Separate configuration file async-webapi.xml will be used to define this mapping.

The array of the entities can be published to the meesage queue both as one message per entity and as an array of entities.

The is an example of configuration which assign a topic for every element of the input array:

<route url="/async/V1/products" method="POST">
    <item topic="products.created" />
    <resources>
        <resource ref="Magento_Catalog::products" />
    </resources>
</route>

The configuration which will map one topic for the whole array of messages defined in the following way:

<route url="/async/V1/products" method="POST">
    <input topic="products.created" />
    <resources>
        <resource ref="Magento_Catalog::products" />
    </resources>
</route>

Endpoint will be mapped to the topic configured in the communication.xml:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
    <topic name="catalog.product.create" schema="Magento\Catalog\Api\ProductRepositoryInterface::save"></topic>
</config>