Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MQTT message expiry interval #1756

Merged

Conversation

dimabarbul
Copy link
Contributor

Resolves #1729

Please, be patient. As I'm C# developer, I assume, there are moments done in non-Java way. If you find some names or language constructs that feel strange or non-Java-like, I'd be grateful if you point them out to me.

My concerns are:

  1. In class ExternalMessageToMqttPublishTransformerTest constant RETAIN_FALL_BACK was not used. It might have been used in method:

    @Test
    public void transformExternalMessageWithoutRetainValueInHeadersFallsBackToFalse() {
        Mockito.when(externalMessage.getHeaders()).thenReturn(DittoHeaders.empty());
    
        assertThat(ExternalMessageToMqttPublishTransformer.transform(externalMessage, mqttPublishTarget))
                .isEqualTo(TransformationSuccess.of(externalMessage,
                        GenericMqttPublish.builder(MQTT_TOPIC_FALL_BACK, MQTT_QOS_FALL_BACK)
                                .retain(false)
                                .build()));
    }

    I believe, as long as the method is named as "*FallsBackToFalse" it's ok to use false instead of class constant.

  2. I'm not sure about implementation of class MessageExpiryInterval, especially about method getAsOptionalLong. I was choosing between Optional<Long> and OptionalLong. I chose OptionalLong because it doesn't do boxing and it has only 2 states - does or doesn't have value, whereas Optional<Long> allows 3 states - doesn't have value, has null value and has not-null value.

  3. Header name mqtt.message-expiry-interval seems a bit long. I thought about mqtt.expiry but decided to stick with MQTT 5 name.

  4. In class GenericMqttPublish I didn't know what to do when we got message from broker with invalid message expiry interval. I decided to not throw any exception and just fall back to no message expiry interval. Probably, need to log something here. Throwing exception doesn't seem to be an option here, cause it'll be needed to be added to signatures of whole call tree of this method.

  5. I added MQTT version to enum MqttHeader. Not sure if adding this kind of info to enum is OK in general.

  6. I consider adding message expiry interval to last will message as out-of-scope.

Signed-off-by: Dmitriy Barbul <dimabarbul@gmail.com>
Signed-off-by: Dmitriy Barbul <dimabarbul@gmail.com>
Signed-off-by: Dmitriy Barbul <dimabarbul@gmail.com>
@thjaeckle thjaeckle added this to the 3.4.0 milestone Sep 21, 2023
@thjaeckle
Copy link
Member

Thanks a lot for the contribution @dimabarbul
I will try to look at it soon 👍

Copy link
Member

@thjaeckle thjaeckle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dimabarbul
Looks really good, thanks a lot. 👍
I only added a few comments, mainly about missing javadoc on public methods.

Copy link
Member

@thjaeckle thjaeckle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the contribution @dimabarbul 👍

@thjaeckle thjaeckle merged commit 2c94cc2 into eclipse-ditto:master Oct 2, 2023
3 checks passed
@dimabarbul dimabarbul deleted the add-mqtt-message-expiry-interval branch October 3, 2023 03:41
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add support for MQTT 5 message expiry interval property
2 participants