DEV Community

Discussion on: How to use ZeroMQ Pub/Sub Pattern in Node.js

Collapse
 
kosm profile image
Kos-M

i'm not sure if is good practice to block loop with that for .
I saw that in the examples of zeromq too.
I could prefer better , events for example sokcer.on('msg', (msg, topic)=>{} )
Do anyone knows if events are possible there ?
Some examples/patterns uses events and some others uses these loops .

Collapse
 
franciscomendes10866 profile image
Francisco Mendes

Here is a list of events that you can use with the package used in this article and that is recommended by the zeromq documentation. -> bit.ly/3mzMXFH

Even though we're blocking the event loop with the for loop, I don't think we're compromising our application too much because each message is handled quickly. But yes, I would also prefer to use events.

Collapse
 
kosm profile image
Kos-M

yeah i know , this is for an example/demo . code should runs ok . I had in mind the integration of that in a more complex system , when i wrote comment above :)
By the way i'm trying to create a small lib/system to pass work from master to workers , with msg queues , to achieve distributed computing , its under development and enough buggy at the moment but you can take a look if you want :)
github.com/queue-xec

Thread Thread
 
franciscomendes10866 profile image
Francisco Mendes • Edited

I understood. I would only use ZeroMQ in personal projects and very small applications.

Otherwise I would use Redis in most cases and in more advanced projects I would use RabbitMQ.