I’ve got a subscribe method in my Service Layer which is used throughout the code to subscribe to any topics:
public void subscribe(String topic, int qos) {
mqttClient.subscribeWith()
.topicFilter(topic)
.qos(MqttQos.fromCode(qos))
.callback(
message -> //expression
)
)
.send();
}
I want to define some method that can be passed as an argument to .callback
which performs differently depending on the topic name.
I’m using the Spring Framework so ideally I’d like to this in as extensible a manner as possible (The dream solution would be simply adding a new @Service class to process a topic for every new topic my service needs to process).
Any ideas/ assistance would be much appreciated!