Transcript
Page 1: Advanced MQTT and Kura - EclipseCON 2014

Advanced MQTT and Kura

Best Practices for Topic Namespaces in M2M

Applications

EclipseCon 2014, March 19th

Page 2: Advanced MQTT and Kura - EclipseCON 2014

IOT MQTT System Topology

Sensors

Actuators

Legacy

Systems

Smart

Machines

M2M

Multi

Services

Gateway

Human /

Machine

Interfaces

Meters

Console/Port

al

APIs

Business

Logic

Page 3: Advanced MQTT and Kura - EclipseCON 2014

Request and Response in MQTT Use cases

• Device Firmware/Software Updates

– Did the device get the update? When? Was it valid & installed?

• Configuration Updates

– Same Questions…

• Remote Resource Control/Interaction

– Device management/Backend business logic needs to

start/stop/interact with a device side service

• Control of actuators

• Dynamic status requests

• Remote Command execution

• Remote Service Control/Interaction

• Other considerations

– Extensibility, mutitenancy, client addressing, multiple applications,

resource management…

Page 4: Advanced MQTT and Kura - EclipseCON 2014

MQTT Topic Space Considerations

• Data Topics

– Used for push of sensor data, metrics, or other data

– Example: [account_id]/[client_id]/...

• Control Topics

– Used for dynamic request/response interactions between clients

– Example: CTL/[account_id]/[client_id]/[app_id]/…

• Separate data from control topics

– Provides increased granularity on ACLs

– Allows for segregation of persistent and transient data

Page 5: Advanced MQTT and Kura - EclipseCON 2014

MQTT Request Verbs

• Request

– CTL/[account_id]/[client_id]/[app_id]/GET/[resource_id]

– CTL/[account_id]/[client_id]/[app_id]/POST/[resource_id]

– CTL/[account_id]/[client_id]/[app_id]/PUT/[resource_id]

– CTL/[account_id]/[client_id]/[app_id]/DEL/[resource_id]

– CTL/[account_id]/[client_id]/[app_id]/EXEC/[resource_id]

• Response

– CTL/[account_id]/[requester_client_id]/[app_id]/REPLY/[req_id]

REST Like

Page 6: Advanced MQTT and Kura - EclipseCON 2014

Request/Response Example Flow Responder

(device1)

Requester

(manager1)

Responder

Subscribes on request topic:

CTL/kura/device1/CONF-V1/GET/configurations

Requester

Generates request metadata (for request payload):

request_id: 1363603920892

request_client_id: manager1

Subscribes on reply topic:

CTL/kura/manager1/CONF-V1/REPLY/1363603920892

Requester

Sends MQTT request

CTL/kura/device1/CONF-V1/GET/configurations

Responder

Handles request and generates response using request

specific parameters in the payload of the request

• [request_id] and [request_client_id] included in

request payload

• Manditory response code

• Optional application specific parameters

• Optional logs, exceptions, stacktraces, etc

Responder

Sends response to requesting client

CTL/kura/manager1/CONF-V1/REPLY/1363603920892

Page 7: Advanced MQTT and Kura - EclipseCON 2014

Response Codes

• response_code

– 200 (RESPONSE_CODE_OK)

– 400 (RESPONSE_CODE_BAD_REQUEST)

– 404 (RESPONSE_CODE_NOTFOUND)

– 500 (RESPONSE_CODE_ERROR)

• response_exception_message

– Optional and contains error message if an error occurred

• response_stacktrace_message

– Optional and contains a stacktrace

HTTP Like

Page 8: Advanced MQTT and Kura - EclipseCON 2014

Kura Cloudlet

• Uses Kura Cloud Client

– Allows for one MQTT connection across many applications

– Built in configurable store/forward of messages on device

– Handles callback routing to applications based on [app_id]

• Offers simple overrides for request/response operations

Page 9: Advanced MQTT and Kura - EclipseCON 2014

Kura Cloudlet

Page 10: Advanced MQTT and Kura - EclipseCON 2014

Thank You


Recommended