HiveMQ Edge: Get mqtt messages from Broker and batch them

Hi there,

I am working with the HiveMQ Edge and I was wondering if it is possible to access MQTT messages from either the inbound broker or the internal broker?

My goal is to collect a few messages and group them into one message/batch. Do you have any idea how I can accomplish this?

Best Regards
Till

Hi Till,

Welcome aboard to the HiveMQ Community! It’s fantastic that you’re interested in MQTT and the HiveMQ broker. We’re thrilled to have you as part of our community.

To better understand your use case and provide the most effective solution, I have a couple of clarifying questions:

  1. Message Aggregation Criteria: Based on what criteria would you like the HiveMQ Edge broker to aggregate the incoming messages? Is it based on the MQTT topic of the message, a user property, or a property contained inside the (possibly encoded) payload of the message?
  2. Publishing Topic Calculation: How should the broker determine the topic to publish the aggregated message to? Should it be based on the incoming message topic or the subscriber client ID?

Your answers to these questions will help us tailor the solution to fit your specific needs. Thank you!

Regards,
Dasha from the HiveMQ Team

Hello @Daria_H,

regarding your second question it would be fine if the outgoing topic is the same as the incomming one.

So it would be fine when I can collect the incomming payloads and concatenate them in the following way with a timestamp:

{ “batch”: [
{
“timestamp”: XXX,
“payload”: INCOMMING-PAYLOAD-1
}, {
“timestamp”: YYY,
“payload”: INCOMMING-PAYLOAD-2
},

]

So I guess the answer to your first question is based on the MQTT Topic.

I have thougt that maybe the InboundInterceptor could help, but I have no idea how to use it in a custom protocol adapter.

Best Regards
Till

Hi @adtlmoe

Perhaps you could make use of Data Hub: Data Hub On Edge :: HiveMQ Documentation?

Let me know your thougts.

Regards,
Dasha from the HiveMQ Team

Hi @Daria_H ,

at first this seems to be a solution. But when I run my edge it says that: Data Hub on Edge is available under a commercial license. And later on this solution must be a production solution which raises a licence Problem I guess.

So I need an open-source solution.

Best Regards
Till

Hi @adtlmoe,

Thank you for sharing more details about your use case. Based on your explanation, it seems you need to prevent delivering outbound publish messages to the subscriber and instead accumulate these messages in storage based on the topics. You would then allow the messages through once you’ve accumulated a sufficient number.

To prevent the delivery of the publish packet to a subscriber, please refer to the HiveMQ Extension Developer Guide on Preventing Delivery of a PUBLISH Packet.

Regarding the best way to accumulate messages in memory, I regret that I don’t have the expertise to provide detailed advice. Perhaps someone with deeper Java skills could assist you with this aspect.

I hope you find the right solution, or perhaps you could even propose an enhancement for HiveMQ Edge!

Best regards,

Dasha from the HiveMQ Team