Publish / Subscribe MQTT using Smallrye reactive messaging dynamically

We try to publish and subscribe to MQTT protocol using smallrye reactive messaging. We managed to actually publish a message into a specific topic/channel through the following simple code

import io.smallrye.mutiny.Multi; import org.eclipse.microprofile.reactive.messaging.Outgoing; import javax.enterprise.context.ApplicationScoped; import java.time.Duration;  @ApplicationScoped public class Publish {          @Outgoing("pao")     public Multi<String> generate() {         return Multi.createFrom().ticks().every(Duration.ofSeconds(1))                 .map(x -> "A Message in here");     } } 

What we want to do is to call whenever we want the generate() method somehow with a dynamic topic, where the user will define it. That one was our problem but then we found these classes from that repo in github. Package name io.smallrye.reactive.messaging.mqtt

Does anyone has used these classes and has some experience cause we got few problems in here. For example we found that there is a class that says it makes a publish call to a MQTT broker(Mosquitto server up).

Here in that statement SendingMqttMessage<String> message = new SendingMqttMessage<String>("myTopic","A message in here",0,false); We get the a red underline under the SendingMqttMessage<String> saying ‘SendingMqttMessage(java.lang.String, java.lang.String, io.netty.handler.codec.mqtt.MqttQoS, boolean)’ is not public in ‘io.smallrye.reactive.messaging.mqtt.SendingMqttMessage’. Cannot be accessed from outside package

Someone with experience on that subject can guide us a bit here cause we are unsure exactly about the error and if we are using the correct class. Thanks in advance

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.