def watch_finished_messages(cond, registered, request_type, request_id, environment): def callback(message): if 'request_id' not in message.body or message.body[ 'request_id'] != request_id: return with cond: global request_state request_state = message.body cond.notify() queue = str(uuid.uuid4()) def registered_cb(consumers): for consumer in consumers: if consumer.queue == queue: registered.set() break def error_cb(failure): print(f"Consumer hit failure {failure}") reactor.stop() # pylint: disable=E1101 # use the public config for this; see related comment in send_message() conf.load_config(FEDORA_MESSAGING_PUBLIC_CONF[environment]) bindings = [{ 'exchange': 'amq.topic', 'queue': queue, 'routing_keys': [get_request_finished_topic(request_type, environment)] }] queues = { queue: { "durable": False, "auto_delete": True, "exclusive": True, "arguments": {} } } consumers = twisted_consume(callback, bindings=bindings, queues=queues) consumers.addCallback(registered_cb) consumers.addErrback(error_cb) reactor.run(installSignalHandlers=False) # pylint: disable=E1101
def send_message_impl(config, topic, body): if config: conf.load_config(config) publish(message.Message(body=body, topic=topic))
def send_message_impl(config, request_type, environment, body): if config: conf.load_config(config) publish( message.Message(body=body, topic=get_request_topic(request_type, environment)))