Zaks
Zaks

Reputation: 700

Rabbitmq message block

10.1.0.30 and 10.1.0.40 are processes communicating with each other. I need a way to block unless the other returns

Below is the sample code:

Running on server 10.1.0.30

def generate_execution_plan():

    channel.basic_publish(exchange='AAA',
                      routing_key='AAA',
                      body=json_data)

//  I need to block here unless  I receive callback from 10.1.0.40 .

Running on server 10.1.0.40

There is one more process running on server subscribed to topic on 'AAA'. This process post message back to 10.1.0.30

Is there any way to block on any topic indefinitely before proceeding

Upvotes: 0

Views: 43

Answers (1)

Olivier
Olivier

Reputation: 2681

This seems to me like this example Remote Procedure Call should match your requirement.

Rpc diagram - available at provided link

Diagram provided at www.rabbitmq.com

The idea is you have the 10.1.0.40 process reply to a specific queue when he's done, and in the code of process located at 10.1.0.30 you listen to the queue. The listener (if configured properly) will listen indefinitely for the reply (although I would personally recommend the implementation of some kind of timeout)

Upvotes: 3

Related Questions