quarkiverse / quarkus-hivemq-client

Quarkus HiveMQ Client extension
Apache License 2.0
5 stars 5 forks source link

MQTT metadata ignored in new Smallrye Messaging version inside Quarkus 3.8 #233

Closed masini closed 6 months ago

masini commented 6 months ago

Upgrading to Quarkus 3.8 and the new SmallRye version we have a regression.

Using MQTT metadata inside a message

messaggi.send(MqttMessage.of(topicNameSpace, objectMapper.writeValueAsBytes(messaggio)));

is now ignored.

The problem is inside the HiveMQMqttSink class where there is an if expecting a custom Smalrye SendingMqttMessage object:

        if (msg instanceof SendingMqttMessage) {
            MqttMessage<?> mm = ((SendingMqttMessage<?>) msg);

We need to use the standard Eclipse Microprofile org.eclipse.microprofile.reactive.messaging.Message, this way:

        Optional<SendingMqttMessageMetadata> sendingMqttMessageMetadata = msg.getMetadata()
                .get(SendingMqttMessageMetadata.class);

        if (sendingMqttMessageMetadata.isPresent()) {
            var mm = sendingMqttMessageMetadata.get();

from here the code is unchanged.