#p2p #client #mqtt #message-broker #topic

rmqtt-p2p-messaging

An rmqtt plugin that provides point-to-point (P2P) messaging support, enabling direct message delivery between clients using configurable topic patterns

9 releases (5 breaking)

0.21.0 May 30, 2026
0.20.0 May 2, 2026
0.19.1 Mar 29, 2026
0.18.1 Dec 8, 2025
0.16.1 Sep 19, 2025

#40 in #topic


Used in 2 crates

MIT/Apache

535KB
12K SLoC

English | 简体中文

rmqtt-p2p-messaging

crates.io

Peer-to-peer messaging plugin for RMQTT. Enables direct client-to-client message delivery over MQTT topics.

Overview

Provides a peer-to-peer messaging mechanism where one client can send messages directly to another specific client using a topic pattern that includes the target client ID. Messages are delivered only to the intended recipient client, not broadcast to all subscribers.

Topic Format

The plugin supports three modes for P2P topic format:

Mode Topic Pattern Description
prefix p2p/{clientid}/{topic} The p2p identifier is at the start of the topic
suffix {topic}/p2p/{clientid} The p2p identifier is at the end of the topic
both Both patterns Supports both prefix and suffix formats

When a client publishes to a P2P topic (e.g., p2p/target-client-id/sensors/temp), the message is routed only to the client identified by target-client-id.

Usage

Add the dependency to Cargo.toml:

rmqtt-p2p-messaging = "0.22"

Register the plugin in your broker startup code:

rmqtt_p2p_messaging::register(&scx, true, false).await?;

Configuration

File: rmqtt-p2p-messaging.toml

Option Type Default Description
mode String "prefix" P2P topic format: "prefix", "suffix", or "both"

Default Configuration

mode = "prefix"

Example: Publishing with prefix mode

Client A wants to send a message to Client B:

  • Publish topic: p2p/Client-B/sensors/temp
  • Content: { "temperature": 23.5 }
  • Result: Only Client B receives the message on sensors/temp

Example: Publishing with suffix mode

mode = "suffix"
  • Publish topic: sensors/temp/p2p/Client-B
  • Content: { "temperature": 23.5 }
  • Result: Only Client B receives the message

Example: Publishing with both modes

mode = "both"

Both prefix and suffix topic formats are recognized:

  • p2p/Client-B/sensors/temp
  • sensors/temp/p2p/Client-B

Dependencies

  • rmqtt (feature plugin)

License

MIT OR Apache-2.0

Dependencies

~24–42MB
~595K SLoC