hivemq / hivemq-mqtt-client

HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support
https://hivemq.github.io/hivemq-mqtt-client/
Apache License 2.0
832 stars 153 forks source link

Message ID, Timestamp, etc headers are not present in Publish message received after subscribing. #549

Closed arihant-confluent closed 1 year ago

arihant-confluent commented 1 year ago

Problem or use case

Message ID, Timestamp, etc headers are not present in Publish message received after subscribing.

Preferred solution or suggestions

Add Message ID, Timestamp etc, fields.

pglombardo commented 1 year ago

Hi @arihant-confluent - a few points & questions:

Message ID

The MQTT specification doesn't have a message ID although there is a protocol packet identifier. Is this what you are looking for?

Currently we don't expose the packet identifiers as they're protocol related (e.g. for QoS >0 negotiation) and generally not useful to app level code.

Let me know what you're looking for here.

Timestamp

Along the same lines, the MQTT doesn't contain timestamps. Published messages do have an optional "Message Expiry Interval" with the note:

The PUBLISH packet sent to a Client by the Server MUST contain a Message Expiry Interval set to the received value minus the time that the Application Message has been waiting in the Server

The Java client could throw a new Timestamp(System.currentTimeMillis()) into received messages but that's generally better for message handling code IMO.

Headers

The closest equivalent in MQTT are User Properties which can be fetched with Mqtt5Publish.getUserProperties().

I hope some of the above helps out. If you're having issues, please let us know so we can help out.

pglombardo commented 1 year ago

Hi @arihant-confluent have you had a chance to look at this yet? Let me know if the above is useful.

pglombardo commented 1 year ago

I'm going to close out this issue but if any questions remain, feel free to open another issue. We'd be happy to help.