Inventory adjusted (Changelog)

Indicates a change in inventory level

Event
  • 2024-08-01 (latest)

    ⭐️ JSON Schema

    Added support for JSON Schema

    InventoryAdjusted uses Avro but now also supports JSON Draft 7.

    Employee JSON Draft
    // labeled-line-markers.jsx
    {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "title": "Employee",
    "properties": {
    "Name": {
    "type": "string"
    },
    "Age": {
    "type": "integer"
    },
    "Town": {
    "type": "string"
    }
    },
    "required": ["Name", "Age", "Town"]
    }

    Using it with our Kafka Cluster

    1. Create a new topic

    Terminal window
    # Create a topic named 'employee_topic'
    kafka-topics.sh --create --topic employee_topic --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1

    Step 2: Prepare the JSON Message

    Create a JSON file named employee.json with the following content:

    {
    "Name": "John Doe",
    "Age": 30,
    "Town": "Springfield"
    }

    Step 3: Produce the Message to Kafka Topic

    Use the Kafka producer CLI to send the JSON message:

    Terminal window
    cat employee.json | kafka-console-producer.sh --topic employee_topic --bootstrap-server localhost:9092

    Step 4: Verify the Message (Optional)

    Terminal window
    kafka-console-consumer.sh --topic employee_topic --from-beginning --bootstrap-server localhost:9092
    schema.avro CHANGED
    {
    0
      "type" : "record",
    1
      "namespace" : "Tutorialspoint",
    2
      "name" : "Employee",
    3
      "fields" : [
    4
    - { "name" : "Name" , "type" : "string" },
    5
    - { "name" : "Age" , "type" : "int" },
     
    6
    - { "name" : "Town" , "type" : "string" },
     
     
    7
      ]
    8
    - }
     
    0
      "type" : "record",
    1
      "namespace" : "Tutorialspoint",
    2
      "name" : "Employee",
    3
      "fields" : [
    4
    + { "name" : "Name", "type" : "string" },
    5
    + { "name" : "Age", "type" : "int" },
    6
    + { "name" : "Department", "type" : "string" },
    7
    + { "name" : "Position", "type" : "string" },
    8
    + { "name" : "Salary", "type" : "double" },
    9
    + { "name" : "JoinDate", "type" : "string", "logicalType": "date" }
    10
      ]
    11
    + }
  • 2024-07-11

    New field

    Added new field to schema

    We added the new town property to the schema for downstream consumers.

    // labeled-line-markers.jsx
    {
    "type" : "record",
    "namespace" : "Tutorialspoint",
    "name" : "Employee",
    "fields" : [
    { "name" : "Name" , "type" : "string" },
    { "name" : "Age" , "type" : "int" },
    { "name" : "Town" , "type" : "string" },
    ]
    }
  • 2024-07-01

    Breaking change

    Removed fields from schema, added new owners

    Gender property has been removed from the Schema of the event

    Also added the full stackers team as owners of this event

    {
    "type" : "record",
    "namespace" : "Tutorialspoint",
    "name" : "Employee",
    "fields" : [
    { "name" : "Name" , "type" : "string" },
    { "name" : "Age" , "type" : "int" },
    { "name" : "Gender" , "type" : "string" },
    ]
    }