SHARE
TWEET

Untitled

a guest Nov 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from kafka import KafkaProducer
  2. import json
  3.  
  4. def sendEvent(server, topic, data, headers):
  5.     producer = KafkaProducer( bootstrap_servers=server, value_serializer=lambda x:  json.dumps(x).encode('utf-8') )    
  6.     producer.send(topic, headers=headers, value=data)
  7.     producer.flush()
  8.  
  9. headersInfo = [
  10.     ("ENTITY_TYPE" ,        b"personalInformation"),
  11.     ("ENTITY_STATUS" ,      b"updated")
  12. ]
  13. headersRegs = [
  14.     ("ENTITY_TYPE" ,        b"prospectRegistration"),
  15.     ("ENTITY_STATUS" ,      b"complete")
  16. ]
  17. headersAccs = [
  18.     ("ENTITY_TYPE" ,        b"account"),
  19.     ("ENTITY_STATUS" ,      b"created")
  20. ]
  21. infos = [
  22.     {"personalInformation":{"status":"updated","updated":"2019-11-16T19:38:50","clientId":"14089867","login":"timson3515@gmail.com","serviceLevel":"SILVER","geography":{"country":"RUS","regionId":"155","city":"Ростов-на-Дону","detectedByGeoIp":False},"organization":{"broker":"BVI","language":"rus","branchId":"385"},"person":{"birthday":"1989-11-22","email":"timson3515@gmail.com","emailValidated":True,"firstName":"Lex","lastName":"Tim","phone":"79054311331","phoneValidated":False,"documentType":"PASSPORT","documentNumber":"6009656888"}}},
  23.     {"personalInformation":{"status":"updated","updated":"2019-11-16T19:41:17","clientId":"14089867","login":"timson3515@gmail.com","serviceLevel":"SILVER","geography":{"country":"RUS","regionId":"155","city":"Ростов-на-Дону","detectedByGeoIp":False},"organization":{"broker":"BVI","language":"rus","branchId":"385"},"person":{"birthday":"1989-11-22","email":"timson3515@gmail.com","emailValidated":True,"firstName":"Lex","lastName":"Tim","phone":"79054311331","phoneValidated":True,"documentType":"PASSPORT","documentNumber":"6009656888"}}},
  24.     {"personalInformation":{"status":"updated","updated":"2019-11-16T19:22:34","clientId":"14089867","login":"timson3515@gmail.com","serviceLevel":"SILVER","geography":{"country":"RUS","regionId":"155","city":"Ростов-на-Дону","detectedByGeoIp":False},"organization":{"broker":"BVI","language":"rus","branchId":"385"},"person":{"email":"timson3515@gmail.com","emailValidated":True,"firstName":"Lex","lastName":"Tim","phone":"79054311331","phoneValidated":False,"documentType":"PASSPORT"}}}
  25. ]
  26. regs = [
  27.     {"prospectRegistration":{"id":"26304675","clientId":"14089867","status":"complete","created":"2019-11-16T13:48:55","type":"REG_WITH_BOTH_ACCOUNTS","updated":"2019-11-16T13:48:55","regStatus":"APPROVED","regStatusReason":"Автоматически одобрена","login":"timson3515@gmail.com","ip":"217.118.81.223","serviceLevel":"SILVER","geography":{"country":"RUS","regionId":"155","city":"Ростов-на-Дону","detectedByGeoIp":False},"person":{"email":"timson3515@gmail.com","emailValidated":False,"firstName":"Lex","lastName":"Tim","phone":"79054311331","phoneValidated":False,"documentType":"PASSPORT"},"organization":{"broker":"BVI","language":"rus","branchId":"385"},"account":{"real":True,"platform":"mt4-market"},"acquisition":{"creationLabel":"fxb-A-14089867","partner":{"code":"35257","network":"CELLXPERT"},"affiliate":{},"landingPageUrl":"https://www.fxclub.org/open-account/trade/meta_market/?aff_id=35257&cxd=35257_356486&registrationStart=1573912134304"},"environment":[{"name":"applicationType","value":"browser"},{"name":"deviceType","value":"PHONE"},{"name":"operationSystem","value":"IOS"},{"name":"cellxpertLink","value":"aff_id=35257&cxd=35257_356486"}]}}
  28. ]
  29. accs = [
  30.     {"account":{"platform":"METATRADER4_MARKET","real":True,"code":"730007953","name":"730007953","login":"730007953","acquisition":{"creationLabel":"fxb-A-14089867"},"environment":[{"name":"Gateway","value":"FXBANK"},{"name":"CountryIso3","value":"RUS"},{"name":"locale","value":"ru"},{"name":"PaymentCountryIso3","value":"RUS"},{"name":"deviceType","value":"PHONE"},{"name":"cellxpertLink","value":"aff_id=35257&cxd=35257_356486"},{"name":"applicationType","value":"browser"},{"name":"operationSystem","value":"IOS"}],"productInstanceId":"MT4_MARKET_REAL2","assetId":"USD","context":"registration","registration":{"type":"REG_WITH_BOTH_ACCOUNTS"},"currencies":["USD"],"clientId":"14089867","status":"created","created":"2019-11-16T13:48:56.000"}},
  31.     {"account":{"platform":"METATRADER4_MARKET","real":False,"code":"770482940","name":"770482940","login":"770482940","acquisition":{"creationLabel":"fxb-A-14089867"},"productInstanceId":"MT4_MARKET_DEMO","context":"registration","registration":{"type":"REG_WITH_BOTH_ACCOUNTS"},"currencies":[],"clientId":"14089867","status":"created","created":"2019-11-16T13:48:56.000"}}    
  32. ]
  33.  
  34. if __name__ == "__main__":
  35.     for event in infos:
  36.         sendEvent('new-kafka-1.fxclub.com:9092', "activemq.events.fxbank.out", event, headersInfo)
  37.     for event in regs:
  38.         sendEvent('new-kafka-1.fxclub.com:9092', "activemq.events.fxbank.out", event, headersRegs)
  39.     for event in accs:
  40.         sendEvent('new-kafka-1.fxclub.com:9092', "activemq.events.fxbank.out", event, headersAccs)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top