coworkers icon indicating copy to clipboard operation
coworkers copied to clipboard

Creating & sending to queue

Open delveintechnolabs opened this issue 8 years ago • 6 comments

Hi,

I have been using this module since a long while. My whole workers app is using the co-workers as base. It is very useful and suffice my needs for creating queue consumer. But when it comes to become publisher, its a bit pain.

I am aware that i can use the context to use publisher channel to publish a message to a queue. But the problem arrives when i have a queue for which i dont want to create a consumer in this app but in other app(in other words i want this app to act as a producer in some situations)

For e.g.: I have two queues startWorking and doneWorking my node application will send a message to startWorking when it has a task. what i want to essentially do is put a message in doneWorking when a message in startWorking is processed by consumer(my node app i.e. the producer of message in startWorking will become consumer of doneWorking) For this i need to consume startWorking and also create a queue doneWorking but not consume it

The main aim of above mechanism is two way communication channel.

The problem is that, co-workers lack on info and documentation as a publisher/producer. Can you please guide me on how this would be possible using co-workers.

I would be really greatfull for your help and reply

Thanks Hannan

delveintechnolabs avatar Jun 30 '16 05:06 delveintechnolabs

Hello Hannan,

I only skimmed over this for now (late night here in SF, CA). Could you provide a very basic code example of what you are describing. I can definitely help you out with this tomorrow, and we can see what needs to be added to coworkers (features or better documentation)

Typed using my thumbs..

On Jun 29, 2016, at 10:41 PM, Hannan Munshi [email protected] wrote:

Hi,

I have been using this module since a long while. My whole workers app is using the co-workers as base. It is very useful and suffice my needs for creating queue consumer. But when it comes to become publisher, its a bit pain.

I am aware that i can use the context to use publisher channel to publish a message to a queue. But the problem arrives when i have a queue for which i dont want to create a consumer in this app but in other app(in other words i want this app to act as a producer in some situations)

For e.g.: I have two queues startWorking and doneWorking my node application will send a message to startWorking when it has a task. what i want to essentially do is put a message in doneWorking when a message in startWorking is processed by consumer(my node app i.e. the producer of message in startWorking will become consumer of doneWorking) For this i need to consume startWorking and also create a queue doneWorking but not consume it

The main aim of above mechanism is two way communication channel.

The problem is that, co-workers lack on info and documentation as a publisher/producer. Can you please guide me on how this would be possible using co-workers.

I would be really greatfull for your help and reply

Thanks Hannan

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

tjmehta avatar Jun 30 '16 07:06 tjmehta

Hannan,

Just checked this out again. I think I understand what you are describing, but a code example would help me understand the scenario better.

Thanks

tjmehta avatar Jun 30 '16 19:06 tjmehta

Hello @delveintechnolabs,

If I understand correctly you are looking for an api to publish jobs to rabbitmq from a non-consumer application? If that it is the case you can just use amqplib. If you are wanting a RPC api checkout amqplib-rpc.

Does that answer your question?

tjmehta avatar Jul 14 '16 01:07 tjmehta

Hello Tejas,

Thanks for your reply and taking time to dig into this problem. Also, apologies for such a late reply somehow these email notifications went overlooked.

Well in a nut shell, there are 2 main players

  1. my node application (that is a producer and will publish messages to queues) Note: this app doesn't use co-workers at all(not needed)

  2. my another node app that uses co-workers to consume queues. So essentially messages sent by 1 will be consumed by 2

Now, what I want is tell 1 from 2 that a message has been processed i.e. When a particular consumer is done processing a message, I want to publish a message in another queue(which I don't want to create consumer for, so I won't do app.queue() because I want my node app I.e. 1 to consume this queue)

(In bed while typing this with thumbs :-) , I'll explain better in a graphical representation tomorrow)

Thanks, Hannan

Sent from my iPad

On 14-Jul-2016, at 06:58, Tejesh Mehta [email protected] wrote:

Hello @delveintechnolabs,

If I understand correctly you are looking for an api to publish jobs to rabbitmq from a non-consumer application? If that it is the case you can just use amqplib. If you are wanting a RPC api checkout amqplib-rpc.

Does that answer your question?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

delveintechnolabs avatar Jul 14 '16 15:07 delveintechnolabs

Actually this explanation is great and what I assumed from your last explanation. Coworkers uses 'amqplib' under the hood, this library is great for publishing and only lacks easy rpc methods. I created 'amqplib-rpc' to make rpc easier, which coworkers also uses under the hood.

Coworkers was designed specifically for consumer applications. I believe currently, if you start coworkers without a queue it will throw an error. The only convenience that coworkers could provide to a publishing app is to quickly create both a rabbitmq connection and channel (which I don't think is that useful).

I will provide you with a short example of using amqplib for publishing a little later

tjmehta avatar Jul 14 '16 17:07 tjmehta

  • [ ] README: add section about how coworkers was designed for consumer applications and provide a short example and link to amqplib docs for publishing

tjmehta avatar Jul 14 '16 17:07 tjmehta