mqtt

package module
v0.0.0-...-89bbdfb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2022 License: Apache-2.0, BSD-3-Clause, MIT Imports: 14 Imported by: 0

README

MQTT

This activity allows you to send message on MQTT Queue.

Installation

Flogo CLI
flogo install github.com/project-flogo/edge-contrib/activity/mqtt

Configuration

Settings:
Name Type Description
broker string The broker URL - REQUIRED
id string The id of client - REQUIRED
username string The name of the user
password string The password of the user
store string The store for message persistence
cleanSession bool Clean session flag
topic string The topic to publish to - REQUIRED
retain bool Retain Messages
qos int The quality of service
sslConfig object SSL configuration
sslConfig Object:
Property Type Description
skipVerify bool Skip SSL validation, defaults to true
useSystemCert bool Use the systems root certificate file, defaults to true
caFile string The path to PEM encoded root certificates file
certFile string The path to PEM encoded client certificate
keyFile string The path to PEM encoded client key

Note: used if broker URI is ssl

Topics

A substitution syntax is supported. For example if the topic is '/x/:/y/:' then the first ':' will be substituted with the value stored in topicParams input key '0' and the second ':' with key '1'. This can also be done with names: '/x/:param1/y/:param2'. The keys used for substitution are now 'param1' and 'param2'

Input:
Name Type Description
message string The message to send
topicParams params The topic parameters
Output:
Name Type Description
data string The data recieved

Example

{
  "id": "mqtt-activity",
  "name": "MQTT Activity",
  "description": "MQTT Example",
  "activity": {
    "ref": "github.com/project-flogo/edge-contrib/activity/mqtt",
    "settings": {
      "broker" : "tcp://localhost:1883",
      "qos": "0",
      "id":"client-1",
      "topic": "flogo"
    },
    "input" : {
        "message" : "Hello From Flogo"
    }
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

Types

type Activity

type Activity struct {
	// contains filtered or unexported fields
}

func (*Activity) Eval

func (a *Activity) Eval(ctx activity.Context) (done bool, err error)

func (*Activity) Metadata

func (a *Activity) Metadata() *activity.Metadata

type Input

type Input struct {
	Message     interface{}       `md:"message"`     // The message to send
	TopicParams map[string]string `md:"topicParams"` // The topic parameters
}

func (*Input) FromMap

func (i *Input) FromMap(values map[string]interface{}) error

func (*Input) ToMap

func (i *Input) ToMap() map[string]interface{}

type Output

type Output struct {
	Data interface{} `md:"data"` // The data recieved
}

func (*Output) FromMap

func (o *Output) FromMap(values map[string]interface{}) error

func (*Output) ToMap

func (o *Output) ToMap() map[string]interface{}

type Settings

type Settings struct {
	Broker       string `md:"broker,required"` // The broker URL
	Id           string `md:"id,required"`     // The id of client
	Username     string `md:"username"`        // The user's name
	Password     string `md:"password"`        // The user's password
	Store        string `md:"store"`           // The store for message persistence
	KeepAlive    int64  `md:"keepAlive"`       // Keep Alive
	CleanSession bool   `md:"cleanSession"`    // Clean session flag

	Retain    bool   `md:"retain"`         // Retain Messages
	Topic     string `md:"topic,required"` // The topic to publish to
	Qos       int    `md:"qos"`            // The Quality of Service
	SSLConfig string `md:"sslConfig"`      // SSL Configuration
}

type Token

type Token struct {
	TokenType TokenType
	Token     string
}

Token is a MQTT topic token

type TokenType

type TokenType int

TokenType is a type of token

const (
	// Literal is a literal token type
	Literal TokenType = iota
	// Substitution is a parameter substitution
	Substitution
)

type Topic

type Topic []Token

Topic is a parsed topic

func ParseTopic

func ParseTopic(topic string) Topic

ParseTopic parses the topic

func (Topic) String

func (t Topic) String(params map[string]string) string

String generates a string for the topic with params

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL