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 configuration 'retain' property for outgoing MQTT message #2665

Merged

Conversation

diversit
Copy link
Contributor

Fixed issue #2663

I did not find any documentation or example to update manually.
As far as I can see, the documentation gets updated automagically with the new connector attribute for outgoing messages.

Added a test to verify the send message contains the 'retain' property set to True, but cannot get this test to succeed.
It seems to go wrong somewhere in the Mqtt client code.
While debugging, I see the retain property is correctly set to true when the message is transformed into a byte[].
But when reconstructing the message from byte[] the retain setting seems to have been lost and therefore the value is False instead of the expected True.

Any idea how to fix this? I'm clueless.

@ozangunalp
Copy link
Collaborator

For the test, you need to start the consumer after the message has been produced. The best way to ensure that is to consume it once and check that retained flag is false, and then consume it again to check that retained flag is true.

@cescoffier
Copy link
Contributor

The code change looks good, but yes, the test might be a bit brittle.

@ozangunalp ozangunalp force-pushed the 2663-add-mqtt-outgoing-retain-config branch from 6c32455 to 3f1bb22 Compare July 2, 2024 10:58
@ozangunalp
Copy link
Collaborator

@diversit I pushed a fix to the test you've added. Note that only the last message is retained with mqtt.

…QTT message.

Note: test fails due to retain property not being received while it _is_ being send.
@ozangunalp ozangunalp force-pushed the 2663-add-mqtt-outgoing-retain-config branch from 3f1bb22 to 518f948 Compare July 3, 2024 15:03
@ozangunalp ozangunalp merged commit d530ed3 into smallrye:main Jul 3, 2024
4 checks passed
@ozangunalp ozangunalp added this to the 4.22.0 milestone Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants