Composite Inventory Extension
Overview
The purpose of this extension is to support use cases where the system of record for inventory is authoritative, but not performant. Therefore we attempt to keep a cache in sync with the authoritative source, but always do lookups against the cache.
- Inventory lookups are always delegated to the cache extension.
- Inventory updates are delegated to both the cache extension and authoritative extension.
Architecture
When in use, the ElasticPathCompositeInventoryFlow
will require at least three extensions to be assigned to the Inventory Flow Extension Point:
- The
ElasticPathCompositeInventoryFlow
extension. As the highest priority Inventory Flow extension, it will be resolved and invoked by Cortex when it looks up the inventory extension. - The cached Inventory Flow extension. This will typically be our internal
ElasticPathJournalingInventoryFlow
extension. - The authoritative Inventory Flow extension. This will typically implement an integration with an external system.
Operations that lookup inventory levels (i.e. getInventory
, getInventories
) will always delegate to the Cached Inventory Flow extension.
Operations that change inventory levels (i.e. allocateInventory
, deallocateInventory
, and releaseInventory
) will:
- Invoke the operation on the Authoritative Inventory Flow extension.
- Invoke the operation on the Cached Inventory Flow extension.
- Log to
TRACE
if there is a difference between the two results (i.e.Authoritative inventory result {} is out of sync with cached inventory result {}
). - Return the authoritative result.
Since the ElasticPathCompositeInventoryFlow
will apply allocate, deallocate, and release operations to both Inventory Flow extensions, they will both be aware of inventory changes as a result of shopper operations. However, this does not account for administrative inventory management necessary to keep the cached inventory fully in sync with the authoritative inventory, such as updating inventory when new inventory is received by a warehouse. A separate process should be implemented to make sure that these types of changes are kept in sync with the cached inventory flow data source.
Configuration
The ElasticPathCompositeInventoryFlow
class is already part of the Elastic Path Commerce source, but it is not assigned to the Inventory Flow Extension Point by default. To assign it to the extension point, create an extensions.json
to enable and configure it, as described in Configuring and Deploying Extensions and Plugins.
The extension has the following required setting values:
Setting Key | Description |
---|---|
CACHED_INVENTORY_FLOW_EXTENSION_CLASS_NAME | The fully-qualified class name of the extension that should be used as the cached inventory flow data source. |
AUTHORITATIVE_INVENTORY_FLOW_EXTENSION_CLASS_NAME | The fully-qualified class name of the extension that should be used as the authoritative inventory flow data source. |
The Cached Inventory Flow extension and the Authoritative Inventory Flow extension must also be assigned to the Inventory Flow extension point. If they are not found, the ElasticPathCompositeInventoryFlow
extension will throw an exception indicating that the extension cannot be found.
Sample extensions.json
:
{
"extensions": [
{
"identifier": {
"extensionClass": "com.elasticpath.service.catalog.impl.ElasticPathCompositeInventoryFlow",
"extensionPointKey": "INVENTORY_FLOW"
},
"enabled": true,
"priority": 1,
"defaultSelectorMode": "DEFAULT_ALL",
"selectors": [
],
"settings": [
{
"key": "CACHED_INVENTORY_FLOW_EXTENSION_CLASS_NAME",
"dataType": "SHORT_TEXT",
"collectionType": "SINGLE",
"values": [
{
"value": "com.elasticpath.service.catalog.impl.ElasticPathJournalingInventoryFlow"
}
]
},
{
"key": "AUTHORITATIVE_INVENTORY_FLOW_EXTENSION_CLASS_NAME",
"dataType": "SHORT_TEXT",
"collectionType": "SINGLE",
"values": [
{
"value": "com.elasticpath.plugins.inmemoryinventoryflow.extensions.InMemoryInventoryFlow"
}
]
}
]
}
]
}