Messaging client library for use by Go implementation of EdgeX micro services. This project contains the abstract Message Bus interface and an implementation for MQTT and NATS.
These interface functions connect, publish, subscribe and disconnect to/from the Message Bus. For more information see the MessageBus documentation.
What is this repository for?
Create new MessageClient
Connect to the Message Bus
Public messages to the Message Bus
Subscribe to and receives messages from the Messsage Bus
Disconnect from the Message Bus
Installation
Make sure you have modules enabled, i.e. have an initialized go.mod file
If your code is in your GOPATH then make sure GO111MODULE=on is set
Run go get github.com/edgexfoundry/go-mod-messaging/v4
This will add the go-mod-messaging to the go.mod file and download it into the module cache
How to Use
This library is used by Go programs for interacting with the Message Bus (i.e. MQTT).
The Message Bus connection information as well as which implementation to use is stored in the service’s toml configuration as:
go-mod-messaging
Messaging client library for use by Go implementation of EdgeX micro services. This project contains the abstract Message Bus interface and an implementation for MQTT and NATS. These interface functions connect, publish, subscribe and disconnect to/from the Message Bus. For more information see the MessageBus documentation.
What is this repository for?
Installation
GO111MODULE=onis setgo get github.com/edgexfoundry/go-mod-messaging/v4How to Use
This library is used by Go programs for interacting with the Message Bus (i.e. MQTT).
The Message Bus connection information as well as which implementation to use is stored in the service’s toml configuration as:
Additional Configuration
Individual client abstractions allow additional configuration properties which can be provided via configuration file:
Or programmatically in the Optional field of the MessageBusConfig struct. For example,
NOTE
For complete details on configuration options see the MessageBus documentation
Usage
The following code snippets demonstrate how a service uses this messaging module to create a connection, send messages, and receive messages.
This code snippet shows how to connect to the abstract message bus.
This code snippet shows how to publish a message to the abstract message bus.
This code snippet shows how to subscribe to the abstract message bus.
This code snippet shows how to receive data on the message channel after you have subscribed to the bus.