Inventory adjusted (v0.0.4)

Indicates a change in inventory level

Event Recently updated! Channel:Apache Kafka


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.

Architecture diagram

Payload example

Event example you my see being published.

Payload example
"Name": "John Doe",
"Age": 30,
"Department": "Engineering",
"Position": "Software Engineer",
"Salary": 85000.50,
"JoinDate": "2024-01-15"

Schema (avro)

Inventory Adjusted Schema (avro)
{ "type" : "record", "namespace" : "Tutorialspoint", "name" : "Employee", "fields" : [ { "name" : "Name", "type" : "string" }, { "name" : "Age", "type" : "int" }, { "name" : "Department", "type" : "string" }, { "name" : "Position", "type" : "string" }, { "name" : "Salary", "type" : "double" }, { "name" : "JoinDate", "type" : "string", "logicalType": "date" } ] }

Producing the Event

To produce an Inventory Adjusted event, use the following example Kafka producer configuration in Python:

Produce event in Python
from kafka import KafkaProducer
import json
from datetime import datetime
# Kafka configuration
producer = KafkaProducer(
value_serializer=lambda v: json.dumps(v).encode('utf-8')
# Event data
event_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 topic
producer.send('inventory.adjusted', event_data)

Consuming the Event

To consume an Inventory Adjusted event, use the following example Kafka consumer configuration in Python:

Consuming the event with python
from kafka import KafkaConsumer
import json
# Kafka configuration
consumer = KafkaConsumer(
value_serializer=lambda v: json.dumps(v).encode('utf-8')
# Consume events
for message in consumer:
event_data = json.loads(message.value)
print(f"Received Inventory Adjusted event: {event_data}")