namarino41
namarino41

Reputation: 123

Subscribe/publish with Express js

I have an Express js server that supplies weather forecast information to its clients. Right now, it's basically an RPC API where the client (a python client in this case) requests different types of weather info from different endpoints. This is fine for right now, but I was thinking about implementing a subscription model. Rather than connecting to different endpoints for different information, the client could just subscribe for the info that it wants and the server would send it every so often (obviously configurable by the client).

Is there a way to do this with express? Would I have to set up a server on the client side as well to listen for the publish events?

Upvotes: 0

Views: 2041

Answers (1)

Pedro Silva
Pedro Silva

Reputation: 2805

A very good option is RabbitMQ, it's used for that right purpose.

I tried to find a good tutorial for you as a reference, however, I only find one in portuguese, but if you search around google you will find others in english.

But it's very simple, just like you want, you publish to the queue on some topic and have other clients subscribing that topic and processing the messages

Here is the link https://medium.com/@programadriano/rabbitmq-publish-subscribe-com-node-js-9363848f58fe

Upvotes: 1

Related Questions