I'd like to create (or ideally use an existing one) a Node-RED node that:
Receives an input.
Publishes a message to either Kafka or MQTT.
Listens to a topic until it receives a response to the original message, processed by an external service.
Writes the response to the output.
Does such a node already exist? Is it possible to create in Node-RED?
# pseudo code: input -> my node -> output
# my node:
id=random()
pub("my_topic_input", id, input)
// other messages may arrive but for other id. They should not be lost as they belongs to other inputs
output = await sub("my_topic_output", id)
return output
Be wary of using context in async things like this. Fast consecutive operations would have concurrency issues. It is doable via arrays or lookup that keep all outbound messages and perform a look up upon response etc. But the link-call mostly takes care of all that.