-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
Description
Description
Currently, afaik, it is not possible to send messages to topics/queues which have not been configured beforehand in applications.properties.
Especially in MQTT environment, it is common to create topics on the fly and subscribe to them.
Implementation ideas
An idea would be to do something like this:
@Inject
//@Broadcast --> should work
Emitter emitter;
@Inject
//@Channel("/house/+/temperature") --> should work: listen to temperatures in all rooms
Publisher publisher;
public void sendMessage(String topic, String payload) {
this.emitter.send(topic, payload);
}
public void subscribe(String topic) {
this.publisher.subscribe(topic, this::handleMessage);
}
public void unsubscribe(String topic) {
this.publisher.unsubscribe(topic);
}