Skip to content

Event-Driven Architectures (EDA)

Event-driven architecture (EDA) is a design paradigm in which a software component executes in response to receiving one or more event notifications. EDA is more loosely coupled than the client/server paradigm because the component that sends the notification doesn’t know the identity of the receiving components at the time of compiling. Gartner

Platform

LKAB used RabbitMQ as the main message broker for EDA services.

Async API Initiative

Open-Source tools to easily build and maintain your event-driven architecture. All powered by the AsyncAPI specification, the industry standard for defining asynchronous APIs. AsyncAPI

Make the data discoverable for consumers

The main focus is to make the data produced on the rabbit brokers discoverable. The consumers is second citizens from the Async API specification perspective.

Version

LKAB supports the 3.0.0 version of the async api specification.

API id

id: urn:com:lkab:rmq:iot:sensor = Unique id for the async service where the name should describe some key concepts
urn:com:lkab = a async service in lkab
rmq = running in rabbit mq
iot:sensor = applikation/function

Routing key

lkab.iot.{sensorId}.temperature = channel name

Exchange

exchange:
  name: lkab.iot.temperature.v1.topic

Payload

temperature:
  type: object
  properties:
    origin:
      type: string
      description: The origin of this temperature
    celcius:
      type: number
      description: Temperature measured in Celcius
    kelvin:
      type: number
      description: Temperature measured in Kelvin
    fahrenheit:
      type: number
      format: number
      description: Temperature measured in Fahrenheit
    created:
      type: string
      format: date-time
      description: Date and time when the tempreture was measured.

Example specification

asyncapi: 3.0.0
id: 'urn:com:lkab:rmq:iot:temperature-sensor'
info:
  title: Temperature sensor API
  version: 1.0.0
  description: |
    The temperature API provides temperature change from sensors
  contact:
    name: LKAB Support
    url: 'https://www.asyncapi.org/support'
    email: support@lkab.com
  license:
    name: Apache 2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0'
  tags:
    - name: iot
      description: Tag for iot services
servers:
  production:
    host: goose.rmq2.cloudamqp.com
    pathname: /hohmawct
    protocol: amqps
channels:
  'lkab.iot.{sensorId}.temperature':
    address: 'lkab.iot.{sensorId}.temperature'
    messages:
      onSensorTemperatureChange.message:
        correlationId:
          location: $message.header#/correlation_id
        name: Temperature
        payload:
          $ref: '#/components/schemas/temperature'
    parameters:
      sensorId:
        description: >-
          Id of the temperature sensor. Use # to get temperatures from all
          sensors
    bindings:
      amqp:
        is: routingKey
        exchange:
          name: lkab.iot.v1.temperature
          type: topic
          vhost: iot
operations:
  onSensorTemperatureChange:
    action: send
    channel:
      $ref: '#/channels/lkab.iot.{sensorId}.temperature'
    description: Recieve a temperature change from a sensor
    messages:
      - $ref: >-
          #/channels/lkab.iot.{sensorId}.temperature/messages/onSensorTemperatureChange.message
components:
  schemas:
    location:
      type: object
      properties:
        name:
          type: string
          description: The first name of the location
        description:
          type: string
          description: The description of the location
    temperature:
      type: object
      properties:
        location:
          $ref: '#/components/schemas/location'
        celcius:
          type: number
          description: Temperature measured in Celcius
        kelvin:
          type: number
          description: Temperature measured in Kelvin
        fahrenheit:
          type: number
          format: number
          description: Temperature measured in Fahrenheit
        created:
          type: string
          format: date-time
          description: Date and time when the tempreture was measured.