Channels
Channels define the routing key and the message transmitted across to the broker. The bindings
part is protocol specific.
Each channel represent the routing key, lkab.iot.{sensorId}.temperature
, used when binding a queue with the specified exchange. The parameters defined on the channel should describe the pattern a consumer could use to retrieve data. The x-example
is a place where you can tell the consuming part how the routing key is composed. In this case the routing key contains the id of the sensor producing the temperatures. With this information the consumer can choose if it would like to recieve data from all sensors or just one specific sensor.
#.temperatures // listen for changes from all sensors
SENSOR-001.temperatures // listen for changes from one specific sensor
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
Operations defines what kind of operation is used through the action
parameter. send
or receive
. In this case the application send temerature updates and has a send
operation defined. With a reference to a channel
.
operations:
onSensorTemperatureChange:
action: send
channel:
$ref: '#/channels/lkab.iot.{sensorId}.temperature'
description: Send a temperature change from a sensor
messages:
- $ref: >-
#/channels/lkab.iot.{sensorId}.temperature/messages/onSensorTemperatureChange.message