Node JS express : robust event driven message

I'm using Node.Js and I would like an algorithm using which looks like :

  • I receive a rest message on node.js using Express
  • Express does all the mecanisms of associated middlewares
  • In the last middleware, I send the response with res.json(...)
  • Then I would like to send the message to a bus with a topik name only if the process succeed
  • Consumers processes (also Rest services in node.js) would have register before to a topik
  • Then all consumers would receive the message

I had a look to Kafka and i saw there are a lot of node.js client package but I would like to know :

  • if anybody already the same algorithm i described
  • how to send a message to a bus as the response is already sent to the client in the last middleware of the list.

Thanks for your help.