ThanhLam112358
ThanhLam112358

Reputation: 917

Route publish message between two MQTT broker

I have a problem with routing publish message between two broker like image below.

How to send message to user B without information about his topic subscribe?

I mean that:

Step 1: I config broker A is bridge broker with broker B

Step 2: User A publish message on topic # to broker A. That's mean broker B will receive message and both of User A and user C will receive this message.

If I only want User C receive message, in STEP 2 I must publish message on exactly topic User B are subscribing. For example:

User A publishes message on topic /home/userB on Broker 1 and User B subscribes topic /home/userB on Broker 2.

And here is my trouble, in practice, Broker 1 represents Organization 1 and Broker 2 represents Organization 2.

User A under Organization 1 can't have information about topic that user B (under Organization 2) subscribe .

enter image description here

Upvotes: 1

Views: 1617

Answers (1)

JD Allen
JD Allen

Reputation: 944

The more IOT systems I put in using MQTT, the more I see this use case.

What you need is an MQTT Proxy. So instead of setting up a "bridge" between the two Brokers, you setup a Proxy that has defined rules about what can be passed over to the other Broker. So if someone Publishes to '/home/UserB' on Broker #1, and there is no 'rule' to pass it on to Broker #2, that is as far as it goes.

The idea is that your proxy Connects to the other Broker, and waits to Publish to it. A list is setup of Topics or Topics/# that will be Published over on the other Broker. I have also setup translations as well IE> /home/UserB => /Org1/status/event to hide what the actual original Topic was.

If the amount of cross-organization traffic is not too heavy, you can do this inside a Container.

I'd post some code, but all the MQTT Proxies I have written is Customer IP. Its not terrible difficult code to write. ...maybe I should write a Public Domain version...

Upvotes: 1

Related Questions