示例#1
0
def callback(ch, method, properties, body):
    m = loads(body)
    print "getting credit score for:", body
    score = getCreditScore(m['ssn'])
    print "got credit score:", score
    m['score'] = str(score)
    publish_to_q("localhost", BANK_ENRICHER_QUEUE, dumps(m), properties)
示例#2
0
def callback(ch, method, properties, body):
    print "raw bank response body:", body
    mtype = properties.correlation_id[8:]
    mid = properties.correlation_id[:8]
    properties.correlation_id = mid
    message = tr.loads(body, mtype)
    message["type"] = mtype
    publish_to_q("localhost", AGGREGATOR_QUEUE, dumps(message), properties)
示例#3
0
def callback(ch, method, properties, body):
    m = loads(body)
    res = loads(body)
    del res["banks"]
    final_message = dumps(res)
    print "received message", body, "sending to", len(m["banks"])
    for t in TRANSLATORS:
        if t in m["banks"]:
            publish_to_q("localhost", t, final_message, properties)    
def callback(ch, method, properties, body):
    properties.correlation_id += "bdo"
    properties.reply_to = NORMALIZER_QUEUE
    m = loads(body)

    print "BDO: ", m

    #pretend to get a response, send to normalizer
    m = loads(tr.dumps(m, "bdo"))
    del m['loanAmount']
    del m['loanDuration']
    rating = random.randint(2, 50)
    m["interestRate"] = rating
    print m
    publish_to_q("datdb.cphbusiness.dk", NORMALIZER_QUEUE, dumps(m),
                 properties)
def callback(ch, method, properties, body):
    m = loads(body)
    # req = "http://127.0.0.1:3001/score/{0}".format(m['score'])
    # print "requesting bank credit score service for score:", m['score']
    # response = requests.get(req)
    # banks = response.json()
    banks = getBanks(int(m['score']))
    m['banks'] = banks
    #prepare aggregator for new message
    await_message = {
        "banks": banks,
        "await_id": properties.correlation_id,
        "type": "await",
    }

    publish_to_q(
        'localhost', AGGREGATOR_QUEUE, dumps(await_message),
        pika.BasicProperties(
            correlation_id="{}await".format(properties.correlation_id)))

    #send to list of banks through recepiant list
    print "received banks:", banks
    publish_to_q("localhost", RECIPIENT_LIST_QUEUE, dumps(m), properties)