Inventory out of stock (v0.0.3)
Indicates inventory is out of stock
Overview
The Inventory Adjusted
event is triggered whenever there is a change in the inventory levels of a product. This could occur due to various reasons such as receiving new stock, sales, returns, or manual adjustments by the inventory management team. The event ensures that all parts of the system that rely on inventory data are kept up-to-date with the latest inventory levels.
Event Details
Event Name
inventory.adjusted
Description
This event indicates that the inventory count for one or more products has been adjusted. The event carries the updated inventory details including the product ID, the new quantity, and the reason for the adjustment.
Payload
The payload of the Inventory Adjusted
event includes the following fields:
{ "event_id": "string", "timestamp": "ISO 8601 date-time", "product_id": "string", "adjusted_quantity": "integer", "new_quantity": "integer", "adjustment_reason": "string", "adjusted_by": "string"}
Producing the Event
To produce an Inventory Adjusted event, use the following example Kafka producer configuration in Python:
from kafka import KafkaProducerimport jsonfrom datetime import datetime
# Kafka configurationproducer = KafkaProducer( bootstrap_servers=['localhost:9092'], value_serializer=lambda v: json.dumps(v).encode('utf-8'))
# Event dataevent_data = { "event_id": "abc123", "timestamp": datetime.utcnow().isoformat() + 'Z', "product_id": "prod987", "adjusted_quantity": 10, "new_quantity": 150, "adjustment_reason": "restock", "adjusted_by": "user123"}
# Send event to Kafka topicproducer.send('inventory.adjusted', event_data)producer.flush()
Consuming the Event
To consume an Inventory Adjusted event, use the following example Kafka consumer configuration in Python:
from kafka import KafkaConsumerimport json
# Kafka configurationconsumer = KafkaConsumer( 'inventory.adjusted', bootstrap_servers=['localhost:9092'], auto_offset_reset='earliest', enable_auto_commit=True, group_id='inventory_group', value_serializer=lambda v: json.dumps(v).encode('utf-8'))
# Consume eventsfor message in consumer: event_data = json.loads(message.value) print(f"Received Inventory Adjusted event: {event_data}")