Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🕸️ MqttDistribNet - A structured distribution network for amqp messaging

The MqttDistribNet module consist of two concepts, to ease the usage of amqp brokers:

  • Dynamic Infrastructure Management
    To simplify the configuration of topics and queues and binding them in a logical path, we introduced an IDistributionNetworkManager and IRemoteDistributionNetworkManager. While the IDistributionNetworkManager is the infrastructure management server, the IRemoteDistributionNetworkManager is used by the client to get information about the remote managed infrastructure.
  • Simple Message Distribution
    Based on Request/Response and Publish/Subscribe Patterns we created Handler, Consumer and Clients to easily configure the wanted behaviour behind queues and reach them by their configured message type.

1. Usage:

import (
    mqttdistribnet "github.com/tjarkpr/mqttdistribnet/pkg"
    amqp "github.com/rabbitmq/amqp091-go"
)

1.1. DistributionNetworkManager

connection, err := amqp.Dial(url)
manager, err    := mqttdistribnet.MakeIDistributionNetworkManager(connection, "<prefix>")
logs, err       := manager.Start(&ctx)

1.2. Distribution & Consumption

connection, err := amqp.Dial(url)
remote, err     := mqttdistribnet.MakeIRemoteDistributionNetworkManager(connection, "<prefix>")
remote.Register(reflect.TypeFor[mqttdistribnet.Envelope[TestRequest]](), "L1.L2.L3.L4.*")
err = mqttdistribnet.MakeRequestHandler[mqttdistribnet.Envelope[TestRequest], mqttdistribnet.Envelope[TestResponse]](
    remote,
    func(request mqttdistribnet.Envelope[TestRequest]) (mqttdistribnet.Envelope[TestResponse], error) {
        t.Log("Request: " + request.ToString())
        return mqttdistribnet.Envelope[TestResponse]{
            MessageId: uuid.New(),
            Timestamp: time.Now(),
            Payload:   TestResponse{TestResProperty: "Test"},
    }, nil
}, &ctx)
request         := &mqttdistribnet.Envelope[TestRequest]{
    MessageId: uuid.New(),
    Timestamp: time.Now(),
    Payload:   TestRequest{TestReqProperty: "Test"},
}
clients, err    := mqttdistribnet.MakeRequestClient[mqttdistribnet.Envelope[TestRequest], mqttdistribnet.Envelope[TestResponse]](remote)
response, err   := slices.Collect(maps.Values(clients))[0].Send(request)

About

MqttDistribNet - A structured distribution network for amqp messaging

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages